Docker Run to Compose Converter
Turn a `docker run …` command into an equivalent docker-compose.yml service definition — ports, volumes, environment, networks, healthchecks, resource limits and more. Runs entirely in your browser.
Input
Output
Guides
The Docker Run to Compose Converter turns a long docker run … command into an equivalent docker-compose.yml service definition. Paste the command you would normally type in your terminal and get a ready-to-save Compose file — no more hand-translating dozens of -p, -v, and -e flags into YAML.
It is built for the moment you find a container in a project's README, a blog post, or your shell history and want to manage it declaratively instead. Compose files are easier to version, review, and restart than a wall of command-line flags.
How to use it
- Paste your full command into the Docker Run Command box, for example
docker run -d --name web -p 8080:80 -v ./html:/usr/share/nginx/html nginx:alpine. - The docker-compose.yml output updates as you type.
- Copy it or download it as
docker-compose.yml, then rundocker compose up -din that directory.
Multi-line commands with trailing backslashes (\) paste in fine — the converter joins the continuation lines before parsing.
What gets converted
The tool understands the flags people actually use: -p/--publish (ports), -v/--volume (volumes), -e/--env and --env-file (environment), --name, --restart, --network, -l/--label, --user, --workdir, --entrypoint, capabilities (--cap-add/--cap-drop), --device, --dns, --add-host, tmpfs, --ulimit, --sysctl, and the health-check flags (--health-cmd, --health-interval, and friends). Resource flags — --memory, --memory-reservation, --cpus, --cpu-shares — are emitted under a deploy.resources block. Any image arguments after the image name become the service command.
FAQ
Does it produce a version key?
No. The top-level version: field is obsolete in the current Compose Specification and is intentionally omitted. Modern docker compose ignores it.
How are named networks handled?
A --network host, none, bridge, or container:<id> value maps to network_mode. Any other network name is treated as a user-defined network: it is added to the service's networks: list and declared at the bottom of the file as external: true, assuming you created it beforehand with docker network create.
Why is --cpu-shares divided by 1024?
Docker's CPU shares are relative weights where 1024 equals one full CPU. Compose's reservations.cpus expects a fractional core count, so the value is converted (for example 512 becomes "0.50").
Will it handle flags I do not recognize?
Flags with no Compose equivalent (such as --rm or -d) are simply dropped, since they describe how the CLI runs rather than the service itself. If the input does not begin with docker run, you get a short comment explaining that instead of a broken file.
Is it a full YAML validator?
No — it emits a clean, correctly quoted Compose file but does not schema-validate against the Compose Specification. Review the result before deploying.
Privacy
The conversion runs entirely in your browser. Your command — including any secrets in environment variables or labels — is never uploaded to a server. Because of that, avoid pasting production credentials, and treat the generated file the same way you would treat the original command.