How to use it
- Paste one or more
docker runcommands. Line continuations with\(or PowerShell’s backtick), single and double quotes, comments and$prompts are all handled. - The
compose.yamlappears on the right. Save it next to your project and start everything withdocker compose up -d. - Choose Service name from: the container’s
--name(default, falling back to the image name) or always the image name (ghcr.io/acme/api:1.2becomesapi).
Commands can be separated by blank lines, ; or &&. docker network create and docker volume create become top-level networks: and volumes: entries, with their --driver. Other commands, such as docker pull, are skipped with a warning. docker container run, docker create and podman run are accepted too.
Example
docker run -d --name cache -p 6379:6379 --restart unless-stopped \
-v redis-data:/data redis:7 redis-server --appendonly yes
becomes
services:
cache:
image: redis:7
container_name: cache
restart: unless-stopped
command: ["redis-server", "--appendonly", "yes"]
ports:
- "6379:6379"
volumes:
- redis-data:/data
volumes:
redis-data: {}
Everything after the image is the command, written as a list so each argument stays exactly as you passed it. Ports are always quoted, because YAML 1.1 parsers read an unquoted value like 22:22 as a base-60 number. Values that YAML would read as booleans, like restart: "no" or DEBUG: "true", are quoted too.
What gets converted
- Basics:
--name,-p,-e,--env-file,-w,-u,--entrypoint,--hostname,--restart,-iand-t(stdin_open,tty),--privileged,--init,--read-only,--label,--platform,--pull. - Storage:
-v(named volumes get a top-level entry;$(pwd)/dataand${PWD}/databecome./data),--mount(bind, volume and tmpfs, written in the long syntax withread_only,bind.propagation,volume.nocopy,tmpfs.size),--tmpfs,--volumes-from. - Networking:
--network(host,none,bridgeandcontainer:…becomenetwork_mode; other names get a top-level entry),--network-alias,--ip,--add-host,--dns,--link,--expose. - Health and limits:
--health-cmdand the--health-*timings,--no-healthcheck,--memory,--cpusand--memory-reservation(underdeploy.resources),--gpus,--ulimit,--pids-limit,--shm-size,--cpu-sharesand block I/O limits. - Security and devices:
--cap-add,--cap-drop,--security-opt,--device,--group-add,--sysctl,--userns,--ipc,--pid.
-d is dropped because docker compose up -d does the same. --rm gets a note, since docker compose down removes the containers.
Secrets in commands
Values from -e are copied into the file as they are. Before you commit compose.yaml, move passwords into an .env file or Docker secrets and refer to them as ${POSTGRES_PASSWORD}. A variable you passed through, like -e "API_KEY=$API_KEY", is already written as API_KEY: $API_KEY, so Compose reads it from your environment.
Errors
A quote that is opened but never closed is reported at its position, for example Unterminated double quote at line 1, column 18 for docker run -d -e "DB_URL=postgres://db/app nginx. A command without an image, or a flag at the end without its value (--name), is reported the same way.
Related tools
The output is plain YAML, so you can check it with YAML to JSON or build one from JSON with JSON to YAML. For HTTP calls copied from your terminal, cURL to Code does the same kind of conversion for curl commands.
Frequently asked questions
Why is there no version: key at the top?
The Compose Specification, used by Docker Compose v2, made the version key obsolete. Current Docker Compose ignores it and prints a warning when it is present, so the file starts directly with services:.
Why did my named volume start empty in Compose?
Compose prefixes the volumes it creates with the project name, so pgdata becomes myproject_pgdata, a different volume from the one docker run created. To reuse the existing volume and its data, add external: true (or name: pgdata) to its entry under the top-level volumes: key.
What happens to flags the converter doesn't know?
They are listed in a warning and left out of the file; the conversion never fails because of them. Known docker run flags that have no Compose equivalent, such as --rm, --cidfile or -P, get a warning that says so.
Are environment variables like $HOME kept?
Yes. A $VAR that your shell would have expanded (unquoted or in double quotes) is written as $VAR, and Compose fills it in from your environment or .env file when it starts. A dollar sign the shell would have kept literally (inside single quotes or escaped as \$) is written as $$, which is how Compose spells a literal $.
Is my command uploaded?
No. The conversion runs in your browser, so passwords and tokens in -e flags stay on your device.
Last updated