Docker Run to Compose
Many project READMEs give you a long docker run command. A Compose file is easier to keep, review and update. Paste the command below and get the same container as a docker-compose.yml. The conversion runs in your browser; nothing is sent anywhere.
The tool converts the common flags and tells you about every flag it can't convert, so nothing disappears silently. Read the result before you run it.
docker-compose.yml
What it converts
- Basics:
--name(container_name),--restart,-p(ports),--expose,-vand--mount(volumes, including bind mounts and read-only),--tmpfs,-eand--env-file,-l(labels),-w,-u,-h,--entrypointand the command after the image. - Network:
--network(a named network orhost),--add-host,--dnsand related,--link. - Security:
--cap-add,--cap-drop,--privileged,--read-only,--security-opt,--group-add,--device,--sysctl,--ulimit,--init. - Resources:
--memory,--memory-reservation,--memory-swap,--cpus,--cpu-shares,--cpuset-cpus,--shm-size,--pids-limit,--oom-score-adj. - Lifecycle and health:
--health-cmdwith its interval, timeout, retries and start period,--no-healthcheck,--stop-signal,--stop-timeout,--log-driverand--log-opt,--platform,--pull,-iand-t.
The names on the Compose side come from the Compose Specification; the flags come from the docker run reference.
What it does not convert
-dis dropped. You start a Compose project detached withdocker compose up -d.--rmhas no Compose setting. For a throwaway container usedocker compose run --rm <service>.-P(publish all exposed ports) is left out on purpose. List the ports you want underports:.--network-aliasbelongs under the network in Compose, so the tool warns instead of guessing.- Anything else it doesn't know is listed in a warning above the output. If an unknown flag takes a value, write it as
--flag=valueso the value isn't read as the image name.
Things to check after converting
- Named volumes are declared at the bottom of the file. Compose adds the project name (usually the folder name) in front of the real volume name, so a volume called
datacan becomemyproject_data. If you want to keep an existing volume, add aname:to it, or the data will look like it vanished. - Dollar signs. Compose reads
$VARas a variable. The tool writes a literal$as$$. Use$VARyourself only if you want Compose to fill it from the environment or an.envfile. - Networks. Names given with
--networkare markedexternal: true, so they must already exist. Delete that line if Compose should create the network. - Port exposure. Docker publishes
-p 8080:80on every interface and bypasses ufw. Read why Docker ignores ufw and bind to127.0.0.1or use a reverse proxy where you can. container_namestops Compose from scaling the service to more than one container, according to the specification. Delete it if you don't need a fixed name.
FAQ
Is it safe to paste my command?
The page runs on your device and doesn't send the text anywhere. Still, replace real passwords and tokens with placeholders before pasting into any web page, and put the real values in a .env file. The secret generator makes strong values.
Does the result match docker run exactly?
For the converted flags, yes. One difference is networking: containers started with plain docker run share Docker's default bridge, while Compose creates a project network where services find each other by name. That's usually what you want.
Which Compose version does it target?
The file has no version: line, which the current Compose Specification doesn't use. Check the output with docker compose config, which prints the resolved file or an error.
What next?
Put a reverse proxy in front with the Compose and Caddy generator or the Docker and Caddy guide, cap memory per container (see the swap calculator and RAM budget), and plan updates with updating Docker containers safely.