Skip to main content
Converter Tools
Recently added

Docker Run to Docker Compose Converter

Convert docker run commands to docker-compose.yml, or turn a compose file back into docker run.

Introduction

Paste a docker run command — including multi-line commands that end with a backslash — and get a docker-compose.yml with a service per container. Optional switches add a version key, change indentation, or move environment values into a .env file. The reverse tab rebuilds a docker run command from a compose service. A written walkthrough is in the guide linked under Related guides.

Supported flags

Common docker run flags and the compose key they become. Anything else is listed in the tool instead of being dropped quietly.

docker run flagdocker-compose.yml key
--name webcontainer_name: web
-p 8080:80ports: ["8080:80"]
-v ./data:/datavolumes: ["./data:/data"]
-e KEY=valueenvironment: ["KEY=value"]
--env-file .envenv_file: .env
--restart alwaysrestart: always
--network mynetnetworks: [mynet]
--cap-add NET_ADMINcap_add: [NET_ADMIN]
--device /dev/dridevices: [/dev/dri]
-l key=valuelabels: ["key=value"]
--health-cmdhealthcheck.test
command argumentscommand
--entrypointentrypoint
-d / --rmOmitted (use docker compose up -d)

Features

  • docker run → compose and compose → docker run
  • Several commands become one compose file
  • Extract environment values to a .env file
  • Lists flags that were not converted
  • Copy or download the YAML, .env, or shell commands

How to use

  • 1
    Paste one or more docker run commands, or switch tabs and paste a compose file.
  • 2
    Choose version, indentation, and whether to extract env vars.
  • 3
    Copy or download docker-compose.yml (and .env, if you extracted secrets).

Example

nginx with a bind mount

Input
docker run -d --name web -p 8080:80 -v ./html:/usr/share/nginx/html:ro -e TZ=Asia/Karachi --restart unless-stopped nginx:alpine
Output
services:
  web:
    image: nginx:alpine
    container_name: web
    ports:
      - "8080:80"

Benefits

  • Use Run to Compose without installing a desktop app or browser extension.
  • Works well alongside JSON ↔ YAML and YAML Format for adjacent steps in the same workflow.
  • Results stay in this browser tab until you copy or download them.

FAQs

Docker Compose describes containers in a YAML file so you can start and stop a whole stack with docker compose up and docker compose down, instead of retyping docker run flags.

Yes. Conversion runs in your browser. Commands, passwords, and environment values are not uploaded.

Yes. Paste several docker run commands separated by a blank line or another docker run. Each one becomes a service in the same file.

The current Compose Specification, with no version key, is the default. Turn on Include version: key if you want version: "3.8".

Yes. Open the compose → docker run tab, paste a compose file, and copy the docker run command for each service.

Most everyday flags (name, ports, volumes, environment, restart, networks, capabilities, devices, labels, healthcheck, command, entrypoint) are mapped. -d and --rm are omitted because Compose handles them. Any other flag is listed in a warning so it is not dropped silently.

No. Run to Compose runs in your browser. Your input is processed locally and is not sent to EverydayDevTools servers.

Related guides

Read the guide: How to Convert docker run to Docker Compose (Free Online Tool)

Learn how to turn any docker run command into a docker-compose.yml file, flag by flag, and convert it instantly with our free in-browser converter.


Developer resources