Generators / LOCAL TOOL

Docker Run to Compose Converter

Turn a docker run command into a Compose service, with every flag it cannot translate reported.

Runs locally — input is never uploaded
Paste a docker run command
Ready when you are

WHAT IT DOES

The command you ran once, as the file you keep.

Paste a docker run command and get the Compose service it describes. Ports, environment variables, volumes, labels, healthchecks, logging, resource limits, and around sixty other flags are translated to their Compose keys. The command is split the way a shell splits it, so a quoted healthcheck stays one argument, and a command pasted across several lines with backslashes converts as written.

Why use it?

Use it to turn a one-off container command into a reviewable service definition while seeing which run-time flags do not translate.

How to use this tool

  1. Paste the complete docker run command, retaining quotes and arguments after the image, then convert.
  2. Review the generated service and comments for unsupported or invocation-only flags. For example, -p 8080:80 must retain host port 8080 and container port 80 in that order.
  3. Replace any real credentials before committing the file, check referenced files and external networks, and validate the result with your installed Docker Compose before starting it. Conversion itself starts no container.

Details and limitations

  • Every flag is either translated or reported. A flag with no Compose equivalent is listed as a comment at the top of the file rather than dropped, because a service quietly missing a capability fails later and in production.
  • The service is named after --name, or after the image when there is no container name, so ghcr.io/acme/api:v2 becomes a service called api.
  • Repeated flags collect into one list, --flag=value and --flag value are read identically, and bundled short flags such as -it are expanded.
  • Flags Compose groups under one key are nested for you: the health and log options become healthcheck and logging blocks.
  • A named network is declared as external at the top level as well as referenced by the service, because Compose refuses a file that references a network it has never heard of.
  • Everything after the image is kept as the container's command, and -d, --rm, and their relatives are explained rather than translated: they describe one run, not the service.

COMMON QUESTIONS

Run → Compose questions

Why is there no version key at the top of the file?
Because the Compose Specification dropped it. Modern Docker Compose ignores version and warns that it is obsolete, so writing one would add a line you would have to delete.
What happens to a flag the converter does not know?
It is named in a comment at the top of the output, along with the reason, and the rest of the service still converts. The converter never skips the flag silently and never guesses at a key, because a Compose file that looks complete and is not is the failure mode worth avoiding.
Does -d belong in the Compose file?
No, and that is the most common surprise. Detaching is decided when you bring the stack up, with docker compose up -d, not by anything in the file. The same is true of --rm, which becomes docker compose down.