Turn docker run commands into a compose.yaml: ports, volumes, networks, health checks
Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.Each docker run flag has a Compose key. The image stays image, and 5 common flags map directly: -p becomes ports, -e becomes environment, -v becomes volumes, --restart becomes restart and --name becomes container_name, while -it maps to stdin_open and tty. Flags such as -d and --rm have no equivalent, since docker compose up -d runs services in the background.
Paste one or more docker run commands, backslash line breaks and all, or click Try an example.
Read the compose.yaml on the right: one service per command, with volumes and networks declared at the bottom.
Check the notes for flags that have no Compose equivalent, such as --rm.
Click Download to save compose.yaml, then run docker compose up -d in the same folder.
A docker run command that works is the best starting point for a compose file, but rewriting 10 flags by hand invites mistakes. Paste the command, or several, and get a compose.yaml with one service each, following the Compose Specification, so it works with docker compose up -d.
| docker run | compose.yaml |
|---|---|
--name web |
container_name: web |
-p 8080:80 |
ports: ["8080:80"] |
-e KEY=value |
environment: ["KEY=value"] |
-v data:/data |
volumes: plus a top-level data: |
--network shop-net |
networks: plus shop-net: external: true |
--restart unless-stopped |
restart: unless-stopped |
-it |
stdin_open: true, tty: true |
--gpus all |
deploy.resources.reservations.devices |
What is understood. More than 70 docker run flags, in every spelling the Docker CLI accepts: --flag value, --flag=value, -p80:80 and grouped short flags such as -it or -dp 3000:3000. Commands broken over lines with \ (bash), ^ (cmd) or ` (PowerShell) are joined, quotes are read as a shell reads them, and $(pwd) in a volume becomes ./, because Compose resolves paths from the compose file's folder.
Several commands at once. Paste a whole setup script: every docker run becomes a service, other commands such as docker network create are skipped, and services sharing an image get distinct names.
Nothing hidden. Flags with no Compose equivalent, like --rm and -d, and any flag the tool does not know are listed under the result instead of disappearing. Ports and environment values are quoted, so no YAML reader takes 22:22 for a number. The file has no version: key, which the Compose Specification made obsolete.
Everything runs in your browser; the commands you paste, which often hold passwords, are never sent anywhere.
Give each flag its Compose key under a service: the image as image, -p as ports, -e as environment, -v as volumes, --name as container_name and --restart as restart. Named volumes and custom networks also get a top-level entry. Pasting the command here writes the whole compose.yaml, ready for docker compose up -d.
The -i flag becomes stdin_open: true and -t becomes tty: true, so -it sets both. The -d flag has no key, because docker compose up -d starts every service in the background. To attach to a running service later, use docker compose attach or docker compose exec with the service name.
Nothing in the file: Compose services are meant to stay, so there is no key that deletes the container when it stops. For a one-off task, run docker compose run --rm with the service name, which removes that container afterwards. The note under the result says when --rm was left out.
A docker run with --network shop-net uses a network that already exists. Marking it external tells Compose to join that network rather than create its own, so containers started both ways can still talk. To let Compose create and own the network instead, delete the external: true line.
Yes, write ports as strings such as "8080:80". Some YAML readers treat two numbers joined by a colon as a base-60 number, so 22:22 could become 1342 and break an SSH mapping. This tool quotes every port, environment entry and volume string so the file means the same everywhere.
No. The Compose Specification made the version: key obsolete, and recent versions of docker compose warn when it is present. Files generated here start straight with services:, followed by volumes: and networks: when the commands use named volumes or custom networks.
Rates and rules change; check the source before you rely on a figure.
Still stuck? Ask about Docker Run to Compose Converter and anybody who knows can answer. No account needed.
Same job, other tools: JSON to YAML – Turn JSON into clean, readable YAML for configs · YAML Validator – Check YAML syntax and see the exact line and column of each error.
On the related tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON.