Docker Run to Compose Converter
Convert docker run commands to docker-compose.yml — parses all flags, nothing sent to any server
Supported Flags Reference
You have a long docker run command with dozens of flags — ports, volumes, environment variables, restart policies, network settings — and you need to move it into a docker-compose.yml file. Translating each flag by hand is tedious and error-prone. This tool parses your docker run command and outputs a valid docker-compose.yml service definition instantly.
Why Convert to Docker Compose?
docker run commands work fine for quick one-off containers, but they become unmanageable when you need to:
- Reproduce environments — A compose file is version-controlled and self-documenting
- Run multi-container setups — Compose handles service dependencies, shared networks, and volume mounts in one file
- Onboard team members —
docker compose upis easier than a 200-character run command pasted in Slack
What Gets Parsed
The converter handles all common docker run flags:
-p/--publish— Port mappings (host:container, with protocol)-v/--volume— Volume mounts (bind mounts and named volumes)-e/--env— Environment variables--name— Service name--restart— Restart policy (no, always, on-failure, unless-stopped)--network— Network configuration-d/--detach— Detached mode--memory/--cpus— Resource limits--entrypoint— Custom entrypoint override--cap-add/--cap-drop— Linux capabilities--privileged— Privileged mode
How to Use
- Paste your
docker runcommand into the input area - The tool parses it and generates the equivalent
docker-compose.yml - Copy the output and add it to your project’s compose file
- Run
docker compose upto verify it works identically
Example
Input:
docker run -d --name redis -p 6379:6379 -v redis-data:/data --restart unless-stopped redis:7-alpine
Output:
version: "3.8"
services:
redis:
image: redis:7-alpine
ports:
- "6379:6379"
volumes:
- redis-data:/data
restart: unless-stopped
volumes:
redis-data:
Frequently Asked Questions
Does this handle multi-line docker run commands?
Yes. Commands split across multiple lines with \ (backslash continuation) are joined and parsed as a single command.
What docker-compose version does it output? The tool generates version “3.8” format by default, which is compatible with Docker Compose V2 and most CI/CD platforms.
Can I convert multiple docker run commands at once? Paste each command separately. The tool converts one service at a time — you can then combine the outputs into a single compose file.
Is my command sent to a server? No. All parsing happens in your browser using JavaScript. No data is transmitted anywhere.
What if my command uses flags the tool doesn’t recognize? Unrecognized flags are preserved as comments in the output so you can manually map them to the appropriate compose directive.