Docker Run to Docker Compose Converter
Convert docker run commands to docker-compose.yml, or turn a compose file back into docker run.
Introduction
Paste a docker run command — including multi-line commands that end with a backslash — and get a docker-compose.yml with a service per container. Optional switches add a version key, change indentation, or move environment values into a .env file. The reverse tab rebuilds a docker run command from a compose service. A written walkthrough is in the guide linked under Related guides.
Supported flags
Common docker run flags and the compose key they become. Anything else is listed in the tool instead of being dropped quietly.
| docker run flag | docker-compose.yml key |
|---|---|
--name web | container_name: web |
-p 8080:80 | ports: ["8080:80"] |
-v ./data:/data | volumes: ["./data:/data"] |
-e KEY=value | environment: ["KEY=value"] |
--env-file .env | env_file: .env |
--restart always | restart: always |
--network mynet | networks: [mynet] |
--cap-add NET_ADMIN | cap_add: [NET_ADMIN] |
--device /dev/dri | devices: [/dev/dri] |
-l key=value | labels: ["key=value"] |
--health-cmd | healthcheck.test |
command arguments | command |
--entrypoint | entrypoint |
-d / --rm | Omitted (use docker compose up -d) |
Features
- docker run → compose and compose → docker run
- Several commands become one compose file
- Extract environment values to a .env file
- Lists flags that were not converted
- Copy or download the YAML, .env, or shell commands
How to use
- 1Paste one or more docker run commands, or switch tabs and paste a compose file.
- 2Choose version, indentation, and whether to extract env vars.
- 3Copy or download docker-compose.yml (and .env, if you extracted secrets).
Example
nginx with a bind mount
Inputdocker run -d --name web -p 8080:80 -v ./html:/usr/share/nginx/html:ro -e TZ=Asia/Karachi --restart unless-stopped nginx:alpineOutput
services:
web:
image: nginx:alpine
container_name: web
ports:
- "8080:80"Benefits
- Use Run to Compose without installing a desktop app or browser extension.
- Works well alongside JSON ↔ YAML and YAML Format for adjacent steps in the same workflow.
- Results stay in this browser tab until you copy or download them.
FAQs
Docker Compose describes containers in a YAML file so you can start and stop a whole stack with docker compose up and docker compose down, instead of retyping docker run flags.
Yes. Conversion runs in your browser. Commands, passwords, and environment values are not uploaded.
Yes. Paste several docker run commands separated by a blank line or another docker run. Each one becomes a service in the same file.
The current Compose Specification, with no version key, is the default. Turn on Include version: key if you want version: "3.8".
Yes. Open the compose → docker run tab, paste a compose file, and copy the docker run command for each service.
Most everyday flags (name, ports, volumes, environment, restart, networks, capabilities, devices, labels, healthcheck, command, entrypoint) are mapped. -d and --rm are omitted because Compose handles them. Any other flag is listed in a warning so it is not dropped silently.
No. Run to Compose runs in your browser. Your input is processed locally and is not sent to EverydayDevTools servers.
Related guides
Learn how to turn any docker run command into a docker-compose.yml file, flag by flag, and convert it instantly with our free in-browser converter.