Convert CLI docker run commands into structured, clean docker-compose.yml files.
Loading tool
About Docker Run to Docker Compose Converter
Paste a docker run command and get an equivalent docker-compose.yml service definition. It understands quoting, line continuations (backslash or PowerShell backtick) and combined short flags like -dit, and maps common options such as ports, volumes, environment variables, env files, networks, restart policy, resource limits, healthchecks, capabilities, devices and logging. Flags that have no Compose equivalent are listed in notes instead of being silently dropped.
Common uses
- Move a container you start by hand into a Compose file
- Convert a docker run example from a project README into docker-compose.yml
- Check which docker run flags do not translate directly to Compose
- Choose between map and list style for the environment section
FAQ
- What happens to -d and --rm?
- Neither has a Compose service equivalent. Services are started detached with docker compose up -d, and one-off containers can be removed with docker compose run --rm, so the tool notes these flags rather than converting them.
- How are named volumes and networks handled?
- Named volumes used with -v are declared in a top-level volumes section. Custom networks are declared at the top level and marked external: true, since docker run expects them to exist already; remove that line if you want Compose to create the network.
- Do I still need the version key in docker-compose.yml?
- No. Current Docker Compose ignores the top-level version key. The tool can add it as an option only for older tooling that still expects it.