docker run ⇄ Compose Converter
Turn docker run commands into a compose.yaml, or a compose file into docker run commands, in the right order, listing anything that does not translate.
● Runs 100% in your browser — nothing you type leaves this page.
The result appears here.How to use it
- Pick a direction: docker run → Compose or Compose → docker run.
- Paste your commands or your
compose.yamlon the left. Severaldocker runcommands become several services;\line continuations,sudo, anddocker network create/docker volume createlines are understood. - Copy the result. Read the Check these box under it: it lists every option that has no exact equivalent on the other side, so nothing is lost silently.
Nothing is uploaded: the conversion runs in your browser, so passwords in environment variables stay on your machine.
docker run → Compose
- Each
docker runbecomes a service, named after--name, or after the image when there’s none. - Ports, volumes (and
--mount), environment variables and--env-file, networks, restart policy, command and entrypoint, user, working directory, memory and CPU limits, healthchecks, labels, capabilities,--add-host, DNS, logging options, ulimits, devices, tmpfs,--privileged,--read-only,--initand more are translated. - Named volumes and custom networks are declared at the end of the file, as Compose requires.
- Ports and values like
"yes"are quoted, so YAML can’t turn them into numbers or booleans. - Left out, and listed:
--rmand-d(Compose manages that for the whole stack),-P,--link,--network-alias, and any option the tool doesn’t know.
Compose → docker run
The result is a shell script you can run as it is:
- Networks and volumes first, named the way Compose names them (
myapp_default,myapp_db-data), with your project name. build:becomes adocker buildbefore the service starts.- Order: services start in
depends_onorder. Forcondition: service_healthy, the script waits until the dependency’s healthcheck sayshealthy, as Compose does. - Names: each container joins the network with its service name as an alias, so
db:5432keeps working between containers. ${VARIABLES}are left for your shell. Load your.envfirst:set -a; . ./.env; set +a.- Listed instead of translated:
profiles,deploy.replicas,secrets,configs,extends, extra networks after the first (with thedocker network connectcommand to run).
FAQ
Why convert at all?
docker run commands get long and end up in shell history, or a wiki. A compose file keeps the same setup in one place, under version control, started with docker compose up -d. The other way round helps on a host without Compose, or to see exactly what Compose does.
Is the result identical to what Compose does?
Very close, not identical. Compose adds its own labels to containers and networks, and handles restarts of the whole stack. The script starts the same containers, with the same options, names and networks.
My file says “is not a docker command” or “Additional property is not allowed”
The first is a missing Compose plugin: see 'compose' is not a docker command. The second is a key Compose doesn’t know at that place: see Additional property is not allowed. Check a converted file with docker compose config.
The containers can’t reach each other
Each one must be on the same network and use the other’s service name, not localhost. See connecting to localhost from a container. If a name or port is already taken by an old container, see container name is already in use and port is already allocated.
Can I start from a template instead?
Yes: the Docker Compose Generator builds a compose file from common services. The Docker Compose cheat sheet has the everyday commands.
Should every service publish its port?
No. Containers in the same project reach each other by service name without ports:, and published ports skip UFW. Publish only what must be reached from outside, on 127.0.0.1 when it’s only for the host. See Docker ports bypass UFW.
Articles
Learn more
docker: 'compose' is not a docker command (and docker-compose: command not found)
Fix "docker: 'compose' is not a docker command" and "docker-compose: command not found": install the Compose plugin, check its folder, and move from docker-compose v1.
Beginner · 3 min read
Docker "Conflict. The container name is already in use": start it, remove it, or rename it
Fix Docker "Conflict. The container name is already in use": find the old container, then start it, remove it, or use --rm, plus the Compose case.
Beginner · 3 min read
Docker "port is already allocated" and "ports are not available": find who has the port
Fix Docker "Bind for 0.0.0.0:8080 failed: port is already allocated" and "Ports are not available": find the container or process using it, and Windows reserved ports.
Beginner · 4 min read
Docker: "connection refused" to localhost from a container — how to reach the host
Fix "connection refused" when a container connects to localhost: use host.docker.internal or a Compose service name, make the host service listen, and check the firewall.
Beginner · 4 min read