Docker Run to Compose Converter

Paste a docker run command and get the equivalent docker-compose.yml service, generated as you type.

You worked out a container with a long `docker run` line, and now you want it in version control as a Compose file — this tool does that conversion for you. Paste the command and it reads the flags the way Docker would: `-p` becomes ports, `-v` becomes volumes, `-e` becomes environment, `--name`, `--restart`, `-w`, `--entrypoint`, and the image and its trailing command all land in the right place. The docker-compose.yml appears on the right the moment you finish typing, ready to copy or download as a file. It’s a straightforward run-to-YAML step for turning an ad-hoc command into a Compose service you can commit, review, and hand to `docker compose up`.

Service web
docker run command
docker-compose.yml

How it works

  1. 1

    Paste the docker run command

    Drop your full `docker run ...` line into the left pane. Backslash line continuations, `-e KEY=value` pairs, and short flags glued to their value like `-p8080:80` all parse correctly.

  2. 2

    Read the generated service

    The right pane writes a docker-compose.yml with your image under `services:`, keyed by the container name (or a name derived from the image), updating on every edit.

  3. 3

    Copy or download the file

    Grab the YAML with Copy, or download it straight as docker-compose.yml to drop into your project and run with `docker compose up`.

Instant & 100% private — nothing is uploaded

Everything runs locally in your browser. Your code, text and files are processed on your own device and are never sent to a server — so there are no upload waits, no size limits from us, and nothing is ever stored or logged.

Frequently asked questions

How do I convert a docker run command to compose?
Paste the command into the left pane. The Compose generator parses the flags and emits a `services:` block: `-p 8080:80` becomes a ports entry, `-v ./data:/var/lib` becomes a volume, `-e KEY=value` becomes an environment line, and `--restart unless-stopped` becomes the restart policy. The result is a valid docker-compose.yml for a single service.
Which docker run flags does it map?
The common ones: `-p`/`--publish`, `-v`/`--volume`, `-e`/`--env`, `--env-file`, `--name`, `--restart`, `-w`/`--workdir`, `--entrypoint`, `-u`/`--user`, `--network`, `--hostname`, `--privileged`, `--cap-add`/`--cap-drop`, `--add-host`, `-l`/`--label`, `-m`/`--memory`, `--cpus`, and `-i`/`-t` for stdin_open and tty. The image and any trailing command are picked up too.
What happens to -d and --rm?
Compose runs detached by default, so `-d` is simply not emitted — nothing is lost. `--rm` has no Compose equivalent (Compose keeps the container so you can inspect and restart it), so it’s dropped and flagged in a note above the output.
How is the service name chosen?
If you passed `--name web`, the service is keyed `web`. Without a name, it derives one from the image — `ghcr.io/acme/api:latest` becomes `api`, `redis:7` becomes `redis` — stripping the registry, org path, and tag.
Is this a full multi-service Compose file?
It converts one `docker run` command into one service. If you’re assembling several services with `depends_on` and shared networks, generate each service here and combine them, or use a visual multi-service builder for the whole file.