Skip to content
Jellykit

Docker Run to Compose Converter

Turn a docker run command into a docker-compose.yml service, or a Compose file back into docker run commands.

  • Runs on your device
Loading tool

About Docker Run to Compose Converter

A long docker run command from a README is hard to keep and easy to mistype. Paste it here, line continuations and quotes included, and get the equivalent Compose service: ports, environment variables, volumes and mounts, networks, restart policy, healthcheck, resource limits, logging and the command itself, with named volumes and networks declared at the top level.

Switch the direction to go the other way: each service in a Compose file becomes one docker run command, ready to paste into a shell. Anything that has no equivalent on the other side is listed under the result rather than silently dropped.

How it works

  1. The command is split into words the way a POSIX shell would, honouring quotes, escapes and backslash line continuations. Variables such as $HOME are kept as written, not expanded.
  2. Each option is matched against docker run’s own list, including grouped short flags like -dit and values written as --name=web, so the image and the command after it are found reliably.
  3. Named volumes are declared with their exact name so Compose uses the same data, and networks are declared as external because docker run only joins networks that already exist.
  4. In the other direction the Compose file is read as YAML, and each service becomes a docker run -d command with one option per line.

Questions

What happens to -d and --rm?

They describe how a container is started, not what it is, so Compose has no field for them. Run docker compose up -d to start in the background; docker compose down removes the containers.

Why is a $ in my command flagged?

Compose replaces $NAME and ${NAME} with values from the environment when it starts, much as your shell did. If you meant a literal dollar sign, write $$ in the Compose file.

Which Compose settings cannot become docker run options?

Settings about building or ordering services, such as build, depends_on, deploy, profiles, secrets and configs. They are listed under the result so you can deal with them yourself.

Is my configuration sent anywhere?

No. Conversion happens in your browser, so passwords in environment variables never leave your device. Input is limited to 1 MB.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.