Docker Run to Docker Compose Converter
Paste one or more docker run commands and get a compose.yaml: ports, volumes, environment, networks, healthchecks, limits. Unsupported flags are listed.
A docker run command that grew over time — ports, volumes, environment variables, a restart policy, limits — is easier to keep in a compose.yaml file and start with docker compose up -d. This converter reads one or more docker run commands with real shell quoting rules and writes the matching Compose services, with named volumes and external networks declared at the top level. Options that have no Compose equivalent are listed instead of being dropped silently.
How to use this tool
- Paste one or more docker run commands (line continuations with \ are fine).
- Read the notes for options that were left out or changed.
- Save the result as compose.yaml next to your .env file.
- Run docker compose up -d.
Formula
-p → ports · -v / --mount → volumes · -e → environment · --name → container_name · --restart → restart · --network → networks · image args → command
Over 70 docker run options are mapped to their Compose Specification fields, including healthchecks, logging, ulimits, capabilities, devices, DNS, memory and CPU limits, and --gpus. A named volume (name:/path) is added to the top-level volumes; a user-defined network is declared external. Quoting follows the shell: single quotes keep $ literal (written $$ for Compose), while $VAR outside single quotes is left for Compose to read from the environment or .env. Ports and anything YAML could misread ("no", 8080:80) are quoted. The YAML is loaded again to check that it says exactly what was converted.
Example
The sample nginx command becomes one service web with image "nginx:1.27-alpine", restart unless-stopped, two ports, the named volume web-data (declared under volumes:) and a bind mount of $PWD/nginx.conf, two environment entries, mem_limit 512m, cpus 1.5, a CMD-SHELL healthcheck every 30s and the command nginx -g "daemon off;". The proxy network is declared external. -d is left out because docker compose up -d does that.
Frequently asked questions
Why is my network marked external?
docker run --network proxy uses a network that already exists. external: true tells Compose to use it instead of creating a new one named after the project. Remove the line if Compose should create it.
Why does $USER become $$USER?
In the command it was inside single quotes, so docker received the text $USER. Compose replaces $VARIABLES itself, so a literal dollar sign must be written $$.
What about --rm and -d?
They change how docker run behaves, not the container. Use docker compose up -d to run in the background; docker compose down removes the containers.
Is my command uploaded?
No. It is converted in your browser, so passwords in environment variables stay on your device.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/docker-run-to-docker-compose-converter/
Cite or embed this tool
kakaoCalc. (2026, November 8). Docker Run to Docker Compose Converter. https://kakao.mobile/tools/docker-run-to-docker-compose-converter/
“Docker Run to Docker Compose Converter.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/docker-run-to-docker-compose-converter/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms