How to use the Docker Run to Compose
- Paste a
docker runcommand — copied from a README, your shell history or Docker Hub. Several commands (one per line or separated by blank lines) become several services. - Line continuations with
\(bash),`(PowerShell) and^(cmd) are handled, as are quotes and--flag=value. - Check the warnings: flags without a Compose equivalent (like
--rm) are listed. - Copy or download
compose.yamland start it withdocker compose up -d.
How docker run flags map to Compose
| docker run | compose.yaml |
|---|---|
--name web | container_name: web (and the service key) |
-p 8080:80 | ports: ["8080:80"] |
-v data:/var/lib/x | volumes: + top-level named volume data |
-e KEY=value, --env-file | environment:, env_file: |
--restart unless-stopped | restart: unless-stopped |
--network mynet | networks: [mynet] + top-level external: true |
-it | stdin_open: true, tty: true |
--memory 512m --cpus 1.5 | mem_limit: 512m, cpus: 1.5 |
--health-cmd … | healthcheck: block |
--gpus all | deploy.resources.reservations.devices |
Things to check after converting
- Relative paths — in Compose,
./datais relative to the compose file, not your current shell directory. - Secrets — move passwords from
environmentto a.envfile and reference them as${DB_PASSWORD}; validate it with the .env File Validator. - Startup order — add
depends_onbetween services yourself; the Docker Compose Generator shows the healthcheck pattern. - --rm has no equivalent: Compose keeps stopped containers until
docker compose down.
Tools that pair well with the Docker Run to Compose
- Nginx Config Generator — Choose what Nginx should do — serve a static site or SPA, proxy to a Node/Python app, or run PHP — and tick the extras.
- YAML to JSON — Paste YAML — a Compose file, Kubernetes manifest or CI config — and get formatted JSON.
- cURL to Code — Paste a curl command — from API docs or “Copy as cURL” in your browser’s DevTools — and get ready-to-run code for six languages, with headers, body and authentication carried over.
- Chmod Calculator — Tick read, write and execute for owner, group and others — or type 755, rwxr-xr-x or u=rwx,g=rx,o=rx.
Frequently asked questions
Can I convert several docker run commands at once?
Yes. Put each command on its own line (or separate multi-line commands with a blank line). Each becomes a service in the same compose.yaml, with shared named volumes and networks merged.
What happens to --rm?
Compose has no per-container auto-remove. Containers are removed with docker compose down, so the flag is listed as a warning and otherwise ignored.
Does it support PowerShell and Windows cmd line breaks?
Yes — backslash (bash/zsh), backtick (PowerShell) and caret (cmd) continuations are all joined before parsing.
Is my command sent to a server?
No. Parsing happens entirely in your browser, so environment variables and passwords in the command never leave your device.