Skip to content
← Back

docker run to Compose Converter - Online YAML Generator

Code
Runs locally · Not uploaded

Convert docker run commands into docker-compose.yml instantly: ports, volumes, env vars, restart policies and networks mapped automatically, with multi-line and --flag=value support. Runs entirely in your browser.

Was this result helpful?

For local tools, open DevTools → Network and search your input — it should not appear in requests.

Usage Guide

A long docker run command works once, but it is hard to maintain across restarts, migrations and orchestration — docker compose turns "how it runs" into a YAML file. This tool translates a docker run command into equivalent compose config, parsed as plain text locally; pasted commands never leave the browser.

1. Convert a run command

  1. Paste the full docker run command (with -d, -p, -v, -e, --name, --restart and friends).
  2. Click convert; the compose YAML appears on the right: port maps land in ports, env vars in environment, volumes in volumes, restart policy in restart.
  3. Save the result as docker-compose.yml and verify once with docker compose up -d.

2. Three manual checks after converting

  • Image and tag: make sure the image field matches the run command exactly — a missing tag silently pulls latest, which may behave differently.
  • Volume paths are host paths: absolute binds need editing when the compose file moves; relative paths resolve against the compose file directory.
  • Startup order: the manual "start the database first" sequence must be expressed with depends_on — the converter will not guess dependencies.

3. Why migrating to compose is worth it

A run command lives only in the session that typed it — after a machine restart it survives in shell history or human memory. A compose file goes into version control: reviewable, rollback-able, reproducible on any machine. The team variant of "works on my machine", container edition, is almost always an unconverted run command.

FAQ

The common 90%: -p ports, -v volumes, -e env vars, --env-file, --name, --restart, --network, -h, -u, -w, --entrypoint, -m, --cpus, --privileged, --mount (bind/volume), plus the container command after the image. Unknown flags never break the conversion — they are listed as warnings for manual review.

A bare -e DEBUG (without =value) passes a host environment variable through, which a compose file cannot express. Rewrite it as -e DEBUG=value and convert again.

At least three spots: a missing image tag silently means latest and behavior may drift; volume paths are host-machine absolutes that break on another box; service dependencies must be expressed with depends_on, which the tool will not guess for you. And keep secret env vars out of any public repo along with the compose file.

Save it as docker-compose.yml and run docker compose up -d once to verify; modern docker compose (v2) needs no version field, which is exactly the format emitted here. A run command lives only in the shell session that typed it, while a compose file in version control is reviewable, revertible, and copyable to any machine.

No. Translation and YAML generation run entirely inside your browser with zero network requests, so commands with passwords or internal hosts can be pasted as-is — just scrub secrets before committing the generated file to Git.

Related Tools

Related Articles