Skip to content

Docker Run to Compose · Docker

The docker run to Docker Compose converter — and back.

A free docker run to docker compose converter: paste a docker run command and get the equivalent docker-compose.yml service, or paste a Compose service to rebuild the command line. Instant, in your browser. No install, no signup.

Runs in your browser — nothing you paste leaves this page. How we prove that

Runs in your browser No signup Bidirectional Updated Jul 29, 2026

Docker Run to Compose converter playground

docker run input

Runs entirely in your browser — nothing is uploaded.

Tip: press Esc to release keyboard focus from the editor.

Output

Pick a mode, load an example or paste your own, then convert to see the result here.

The Gap

One container, two shapes.

A docker run command is great for a quick start, but the moment you want it reproducible — in version control, reviewed in a PR, started with one command — you need to take that docker run command to compose form in a docker-compose.yml. Translating a wall of -p, -v and -e flags by hand is tedious and error-prone: it is easy to drop a flag, mis-nest a list, or quote a port wrong.

This docker run to docker-compose generator does the mechanical part for you, both ways. It tokenises the command exactly like a shell would — respecting quotes, bundled short flags, and line continuations — maps each flag onto the matching Compose key, and emits deterministic YAML to turn docker run into a docker-compose service. Going the other direction it handles docker compose to docker run too: it rebuilds a runnable command from a service and tells you about the keys (depends_on, build, deploy) that simply have no command equivalent.

Because it is a docker run to compose online tool, you can convert a docker run command to docker compose online free with nothing to download — no daemon, no account, no waiting on a build.

Everything runs in your browser, so you can convert commands that name private registries or secret-bearing environment variables without anything leaving the tab. See the docker run reference and the Compose services reference.

See the full flag-to-key mapping, or try the live playground above.

The Pipeline

How to convert docker run flags to docker compose.

Five deterministic steps turn docker run into a docker-compose service end-to-end on every conversion — all inside your browser tab, every time.

  1. Tokenise the command.

    A POSIX-aware tokeniser splits the line, honouring single and double quotes and backslash-newline continuations, so quoted values and multi-line pastes stay intact.

  2. Strip the prefix.

    A leading docker run or docker container run is removed, and bundled short flags like -it or -itp are expanded into their individual flags.

  3. Classify each flag.

    Every flag is mapped onto a service object — ports, volumes, environment, networks, capabilities, limits, labels and healthcheck — and the first positional becomes the image, the rest the command.

  4. Emit deterministic YAML.

    A small hand-rolled writer prints a stable, diff-friendly services: block keyed by the container name (or app), quoting only the scalars that YAML requires.

  5. Or reverse it.

    In compose → run mode the same model is rebuilt from parsed Compose YAML into a docker run command, with Compose-only keys surfaced as warnings.

Reference

Every flag, mapped.

The docker run flags the converter recognises and the docker-compose keys they map to. Anything unrecognised is reported as a note instead of being silently dropped.

docker run flag Compose key
-p / --publish ports Quoted, e.g. "8080:80".
-v / --volume, --mount volumes Short source:target[:ro] form.
-e / --env environment A KEY=value list.
--env-file env_file One or more files.
--name container_name Also the service key.
--restart restart no / always / unless-stopped …
--network / --net networks host / none → network_mode.
-w / --workdir working_dir
-u / --user user
--entrypoint entrypoint
--hostname hostname
--add-host extra_hosts
--cap-add / --cap-drop cap_add / cap_drop
--privileged privileged
-m / --memory mem_limit
--cpus cpus
-l / --label labels
--health-* healthcheck cmd / interval / timeout / retries.
-i / -t stdin_open / tty
--rm, -d / --detach — (warning) No Compose equivalent.

Input

docker run
docker run -d -p 8080:80 --name web \
  -v /data:/usr/share/nginx/html:ro \
  --restart unless-stopped nginx:alpine

Output

docker-compose.yml
services:
  web:
    image: nginx:alpine
    container_name: web
    ports:
      - "8080:80"
    volumes:
      - /data:/usr/share/nginx/html:ro
    restart: unless-stopped

After converting, start the service with docker compose up -d — the Compose equivalent of the original -d flag.

Next Step

Got the service? Validate the pipeline and size the pods.

A Compose service rarely ships alone. Lint the CI that builds and pushes the image with the GitLab CI Validator, and when you move the container to Kubernetes, turn its memory and CPU limits into safe requests/limits with the Kubernetes Resource Calculator — both entirely in your browser.

next.sh
# build, push, deploy
docker build -t app .
docker compose up -d        # ← from this converter
kubectl apply -f deploy.yml # ← size it first

FAQ

Questions, answered.

Tap a question to expand the answer.

Paste the full docker run command into this docker run to compose converter with the mode set to run → compose, then press Convert. It strips the leading docker run, classifies each flag onto a service object, treats the first non-flag token as the image and the rest as the command, and prints a ready-to-use docker-compose.yml services: block — no install, no Docker daemon, and nothing pushed anywhere. The whole convert docker run to docker-compose.yml flow happens in the browser.

Yes — this is a bidirectional docker run / docker compose converter. Switch the mode toggle to compose → run, paste a service definition (or a full Compose file — the first service is used), and it reconstructs an equivalent docker run command, including ports, volumes, environment, networks, capabilities, resource limits and a healthcheck. This docker compose to docker run command converter reports keys with no docker run equivalent — depends_on, build, deploy, profiles — as warnings rather than translating them.

The common docker run flags map cleanly: -p/--publish → ports, -v/--volume and --mount → volumes, -e/--env → environment, --env-file → env_file, --name → container_name, --restart → restart, --network/--net → networks (or network_mode for host/none), -w/--workdir → working_dir, -u/--user → user, --entrypoint → entrypoint, --hostname → hostname, --add-host → extra_hosts, --cap-add/--cap-drop → cap_add/cap_drop, --privileged → privileged, -m/--memory → mem_limit, --cpus → cpus, -l/--label → labels, and the --health-* flags → a healthcheck block. -i and -t map to stdin_open and tty.

Each -p / --publish flag becomes an entry under the ports: list in the Compose service, written as a quoted "HOST:CONTAINER" string — so docker run -p 8080:80 turns into a ports entry of "8080:80". The converter quotes the value because YAML would otherwise read a bare 8080:80 as a sexagesimal number, which is exactly the kind of subtle bug that hand-conversion of docker run -p -v -e to compose tends to introduce.

Every -v / --volume (and --mount) flag is collected into the volumes: list on the service, keeping the short source:target[:ro] form, so docker run -v /data:/usr/share/nginx/html:ro becomes a volumes entry of /data:/usr/share/nginx/html:ro. Named volumes and bind mounts are preserved as written; the tool does not invent a top-level volumes: section you did not ask for.

Each -e / --env flag becomes a KEY=value entry under environment: in the service, and any --env-file is mapped to env_file:. Because the conversion is docker run to compose yaml with no upload, you can safely paste commands whose -e flags carry secret-bearing values or internal hostnames — they are tokenised in your browser and never sent anywhere.

The docker run restart policy maps straight to the restart: key in Compose: --restart no, --restart always, --restart on-failure[:max] and --restart unless-stopped are carried across unchanged. So docker run --restart unless-stopped becomes restart: unless-stopped in the generated service.

Yes. It is a free docker run to compose converter that runs 100% client-side, so it works as a docker run to compose converter that runs in the browser — there is no server, no account and no signup, and once the page has loaded it keeps working with no network. That also makes it a docker run to docker compose converter with no install: nothing is uploaded and nothing is installed on your machine.

New to this? Read our guide on Docker for DevOps.

More free, private DevOps tools.

The Docker Run to Compose converter is one tool in OpsCanopy — a growing canopy of browser-based validators, converters and testers that never touch a server.

New to Docker?  Read the Docker guide →

39 free tools, every one offline-capable — opscanopy.com works with no signup and nothing uploaded.

Related tools: the GitLab CI validator and the Kubernetes resource calculator. Browse the full tools directory.

Not affiliated with, endorsed by, or sponsored by Docker, Inc. Docker, docker run and Docker Compose are trademarks of Docker, Inc., used here only descriptively to identify the command and file formats this tool converts between.