docker run to Docker Compose converter
Convert docker run commands into a compose.yaml, one service per command, with ports, volumes, environment and GPUs.
Input
Result
The result will appear here.Project READMEs tend to start with a docker run command, but once you run more than one container — Open WebUI next to Ollama, an app next to its database — a compose.yaml is far easier to keep. Paste one or more docker run commands and this tool converts each with composerize, the open-source converter behind composerize.com, and combines the results into one Compose file: ports, volumes, environment variables, restart policy, extra hosts and GPU reservations each end up under the right key of their own service.
How it works
- Put one command per line or join them with &&; backslash line continuations, a leading $ prompt, sudo and podman run are all understood.
- Each service is named after the container's --name; without one it takes the image's name, and a repeated name gets a -2 suffix so no container overwrites another.
- Choose the current Compose file format, which has no version key, or the older 3.x and 2.x formats that start with version:, and an indent of two or four spaces.
- The placeholder project name composerize writes is removed, because Compose would reject it; Compose then names the project after the folder the file is in.
Where your data goes
Nowhere. This tool runs entirely in your browser: the text you paste is processed by the page and is never transmitted to a server or written to a log.
This tool is free and needs no account. Its results exist only in your open page and are not saved anywhere.
What it costs
This tool is free, with no sign-in and no points.
Common questions
- Why are my named volumes marked external: true?
- Because a named volume from docker run — -v ollama:/root/.ollama — already exists with your data in it. Marked external, Compose uses that exact volume. Without it, Compose would create a new, empty volume prefixed with the project name. The comment above the file says so. If you are starting fresh, delete the external lines and Compose creates the volumes itself.
- Does --gpus all carry over?
- Yes. It becomes a deploy.resources.reservations.devices entry with driver nvidia, count all and the gpu capability, which is how Compose requests GPUs; the NVIDIA Container Toolkit still has to be installed on the host, exactly as for docker run.
- Should I keep the version: line?
- Not for current Docker. The Compose Specification that docker compose (v2) implements ignores version and prints a warning that it is obsolete, so the default format leaves it out. Choose 3.x or 2.x only if the file will be read by the old docker-compose 1.x or by a tool that expects that key.
- What if an option is not converted?
- composerize maps most docker run options; the few with no Compose equivalent are left out of the file. Compare the result with the original command before relying on it, especially for unusual flags — and remember that the image name must come after all the options, as docker run itself requires.
The open-source behind it
This tool runs on composerize/composerize, released under MIT. If you need the same behaviour inside your own program, that is the library to reach for.
composerize/composerizeAlso known as
- docker run to docker compose
- docker run to compose
- composerize
- convert docker command to compose
- docker compose generator
- docker run to yaml