Docker Run to Compose
Turn a docker run command into a ready-to-use docker-compose.yml file.
Loading Docker Run to Compose… If nothing happens, please enable JavaScript.
Most projects start with a single docker run line copied from a README, and end up as a wall of flags nobody wants to retype. Paste that command here and this tool rewrites it as a docker-compose.yml file, mapping every option it recognises to the matching Compose key: -p becomes ports, -v becomes volumes, -e becomes environment, --restart becomes restart, and so on for roughly seventy flags including healthchecks, resource limits, logging drivers, capabilities, ulimits and GPU reservations.
Frequently asked questions
Is my docker run command sent to a server?
Which docker run options are supported?
Why is -d missing from the generated file?
Do I need the version key at the top of the file?
What happens to named volumes and networks?
Can I convert more than one container at once?
Why are port mappings written in quotes?
Does it understand --mount and healthchecks?
How do I run the file once it is generated?
About Docker Run to Compose
The converter reads the command the way a shell does. Backslash line continuations, single and double quotes, attached short flags such as -p8080:80, clustered flags such as -itd, and the --flag=value form are all handled, so you can paste a command straight out of documentation without cleaning it up first. Paste several commands, one per line or joined with &&, and each one becomes its own service in the same file. Named volumes and named networks used by those services are collected and declared in the top-level volumes and networks sections, and ports are quoted so that a value like 22:22 is not read as a sexagesimal number by the YAML parser.
Flags that only make sense while a container is being launched have no place in a Compose file, and the tool says so instead of silently dropping them: -d is replaced by docker compose up -d, --rm by docker compose down, and options like --cidfile or --detach-keys are listed under Notes with a short explanation. Everything runs in your browser with no server call and no external library, so commands that contain passwords, registry hostnames or internal image names never leave the page. Copy the result or download it as docker-compose.yml and run docker compose up -d in the same folder.
Compose started life as Fig
Before Docker Compose existed there was Fig, a small Python tool released in 2013 by Orchard Laboratories. Fig introduced the idea that a multi-container application should be described in one YAML file and started with a single command, at a time when the usual approach was a shell script full of docker run lines. Docker acquired Orchard in 2014 and Fig became docker-compose the following year, keeping the file format almost unchanged.
The file format then went through a decade of churn. Version 1 had no top-level keys at all, version 2 added services, volumes and networks, and version 3 was shaped by Docker Swarm, which is why keys like deploy still appear in files that will never touch a swarm. The numbering finally ended with the Compose Specification, which merged the version 2 and 3 branches and made the version field obsolete.
The rewrite from Python to Go in Compose V2 also changed how you invoke it: docker-compose with a hyphen became docker compose as a subcommand of the Docker CLI. The old standalone binary reached end of life in July 2023, so if a tutorial still tells you to add version: '3.8' at the top of the file, it was written for a tool that Docker no longer ships.