This tool runs entirely on your device. Your files and the text you enter are processed by your browser and are never sent to a server.
Docker Run to Docker Compose Converter
Paste one or more docker run commands and get a ready-to-use docker-compose.yml, or paste a compose file and get the equivalent docker run commands. Conversion happens in your browser, with notes for any flag that has no direct equivalent.
How to convert docker run to Docker Compose
- Pick a direction. Use the "docker run → Compose" tab to build a compose file, or "Compose → docker run" to go the other way.
- Paste your input. Paste one or more docker run commands (one per line; lines ending in a backslash are joined), or paste a docker-compose.yml. You can also load an example.
- Choose options. Pick the compose format (Compose Specification, 3.x or 2.x) and indent, or for docker run output choose multi-line, -d, --rm and long flag names.
- Copy or download. The result updates as you type. Read any notes about unsupported flags, then copy it or download docker-compose.yml or a .sh script.
docker run flags and their compose keys
Most docker run options map one-to-one to a key under the service in docker-compose.yml. The most common ones:
| docker run | docker-compose.yml |
|---|---|
| -p 8080:80 | ports: ["8080:80"] |
| -v ./data:/data | volumes: [./data:/data] |
| -e KEY=value | environment: [KEY=value] |
| --env-file .env | env_file: .env |
| --name web | container_name: web |
| --restart unless-stopped | restart: unless-stopped |
| --network appnet | networks: [appnet] |
| -m 512m / --cpus 1 | deploy.resources.limits |
| -it | stdin_open: true, tty: true |
| --health-cmd "..." | healthcheck.test |
-d and --rm have no compose key: use docker compose up -d to detach, and docker compose down to remove containers.
Why move from docker run to Compose?
A long docker run command is hard to read, easy to mistype and lives only in your shell history. A compose file puts the same settings in version control, starts several containers with one docker compose up -d, gives them a shared network where they reach each other by service name, and recreates only what changed when you edit it.
After converting, review a few things by hand: put secrets in an .env file instead of inline environment values, quote port mappings, and add depends_on (ideally with a healthcheck) when one service needs another to be ready first.
Related tools
Frequently Asked Questions
How do I convert a docker run command to docker-compose.yml?↓
Paste the command into the docker run → Compose tab. Each flag is mapped to its compose key: -p becomes ports, -v becomes volumes, -e becomes environment, --name becomes container_name and --restart becomes restart. The image and any trailing command go into image and command. Save the result as docker-compose.yml and start it with docker compose up -d.
Can I convert several docker run commands into one compose file?↓
Yes. Put one command per line (multi-line commands with a trailing backslash are joined first). Each command becomes its own service, named after --name when you set one, otherwise after the image. If two commands would create the same service name, the second is renamed so neither is lost.
Should I add version: "3" to my docker-compose.yml?↓
Not for current Docker. Docker Compose v2 follows the Compose Specification, which ignores the top-level version key and prints a warning that it is obsolete. Choose the latest format unless you still run the old Python docker-compose 1.x or a tool that requires version 3.x or 2.x.
Why is my named volume or network marked external?↓
A docker run command that uses -v data:/path or --network mynet refers to a volume or network that already exists. Marking it external makes compose reuse that same object instead of creating a new project-prefixed one, so existing data is kept. Remove external: true if you want compose to create and manage it.
Which compose keys can't be turned into docker run flags?↓
build, depends_on, secrets, configs, profiles, extends and scale only exist in compose. The converter lists them as notes: build the image with docker build first, start containers in dependency order yourself, and mount secrets or configs as files with -v.
Are my commands uploaded anywhere?↓
No. The conversion runs entirely in your browser with the open-source composerize and decomposerize libraries, so passwords in environment variables never leave your device.
You might also need
All Text & Dev Tools →JSON ↔ YAML
Convert between JSON and YAML.
Chmod Calculator
Convert Unix permissions: checkboxes, octal, symbolic.
Cron Expression Parser
Explain and build cron schedules.
IP Subnet Calculator
IPv4 and IPv6 CIDR, ranges and masks.
User Agent Parser
Parse user-agent strings, Client Hints and bots.
HTTP Status Codes
Complete HTTP status code reference.
Last updated: