Docker run to Docker compose converter
Transforms "docker run" commands into docker-compose files!
About Docker run to Docker compose converter
Translates a docker run command into an equivalent docker-compose.yml service definition, mapping ports, volumes, environment variables, restart policy, networks and the other common flags, using the composerize library.
When you would use it
- Turning the one-line docker run from an image's README into a Compose file you can keep in version control.
- Consolidating several containers started by hand into a single stack.
- Learning how a docker run flag is spelled in Compose syntax.
How to use it
- Paste the complete docker run command, including the image name.
- Read the generated Compose file on the right.
- Check the notices below it for flags that could not be translated, then copy the result.
Things worth knowing
- Flags that Compose cannot express, or that the library does not know, are listed as not translatable or not implemented. Review them rather than assuming the output is complete; --rm and -it, for example, have no equivalent because Compose services are long-running.
- Relative volume paths and environment variables are copied as written. Make sure they make sense relative to the directory where the Compose file lives.
- The output describes one service. For several containers, convert each command and merge the services blocks under a single services key.
- Quoting matters: a command with unbalanced quotes or shell line continuations (trailing backslashes) must be cleaned up before pasting.
Frequently asked questions
- Why does the output not include a version key?
- Recent versions of Docker Compose treat the version field as obsolete and ignore it. The generated file follows the current Compose specification, which does not need it.
- How do I start the stack?
- Save the output as docker-compose.yml (or compose.yaml) and run docker compose up -d in the same directory. docker compose down stops and removes the containers.