Docker Run to Compose
Convert docker run terminal commands into clean, readable docker-compose.yml files.
Runs in your browser. Nothing you add is uploaded.
What the Docker Run to Compose does
Paste a docker run command, even one split over several lines with backslashes, and get the equivalent service in a docker-compose.yml in the current Compose Specification format. Ports, volumes, environment variables and env files, restart policy, networks, memory and CPU limits, working directory, user, entrypoint, hostname, added capabilities, extra hosts and labels are all mapped. Arguments after the image become the service's command as a list, so quoted arguments like sh -c "a && b" survive intact, and any flag the converter does not map is listed under the output instead of being dropped silently.
How to convert docker run to Docker Compose
- Paste the command (with or without sudo docker run in front), or pick a preset: Nginx, PostgreSQL, Redis with limits, or a Node app with networks.
- Read the generated YAML. The service is named after --name, or after the image when there is no name.
- Check the warning under the output for flags that were not converted, such as --gpus, and add those to the file yourself.
- Copy the YAML or download docker-compose.yml, then run docker compose up -d in the same folder.
The Docker Run to Compose runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Turning a one-off command into a file
A docker run line with a dozen flags lives in shell history until it is lost. As a compose file it can be committed, reviewed and re-run with docker compose up -d, and changing one port or variable no longer means retyping the whole command.
Starting point for a self-hosted app
Many projects document installation as a single docker run command. Converting it gives you a compose file to build on, adding a database service, a reverse proxy or a backup container next to it.
Seeing what a command really grants
Laid out as named keys (privileged: true, network_mode: host, cap_add), it is obvious when a command copied from a forum gives the container more access than the app needs.
Good to know
- --network host, none or bridge become network_mode. Any other network name becomes an external network, which you are expected to have created with docker network create.
- Bind mounts (./data:/data, /srv/app:/app) stay as paths. A name before the colon (pgdata:/var/lib/postgresql/data) is a named volume and is declared at the bottom of the file.
- -m and --cpus become deploy.resources.limits, which docker compose up applies in current Compose versions.
- container_name is only added when the command used --name. Leaving it out lets Compose name containers itself, which you need if you ever scale the service.
- -d, -it and --rm have no compose equivalent and are dropped: docker compose up -d runs detached, and docker compose run --rm gives a throwaway container.
Frequently asked questions
Why should I convert docker run into Docker Compose?
Does this handle named volumes and bind mounts?
Does this support multi-line docker run commands with backslashes?
What version of Docker Compose is generated?
Why is a flag listed as not converted?
Page last updated . Found a wrong result or a mistake on this page? Let us know.
Related tools
Regex Builder
Build a regular expression from blocks, with live matches.
CSS Box Shadow Generator
Multi-layer CSS box shadows with live preview and Tailwind export.
Glassmorphism Generator
Design frosted-glass panels and copy the CSS or Tailwind classes.
PX to REM Converter
Convert px to rem and build fluid clamp() font sizes.