Docker Run to Docker Compose Converter
Convert docker run CLI commands to production-ready docker-compose.yml files and reverse Compose YAML to docker run commands.
version: '3.8'
services:
postgres-db:
container_name: postgres-db
image: postgres:16-alpine
restart: unless-stopped
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=supersecret
- POSTGRES_DB=production
volumes:
pgdata: null
Common Docker Run Flags & Compose Mapping
| Docker CLI Flag | Docker Compose Attribute | Description |
|---|---|---|
| -p, --publish 8080:80 | ports: ["8080:80"] | Map host port to container port |
| -v, --volume /host:/data:ro | volumes: ["/host:/data:ro"] | Mount directory or named volume |
| -e, --env KEY=val | environment: [KEY=val] | Inject runtime environment variables |
| --restart unless-stopped | restart: unless-stopped | Container lifecycle restart behavior |
| -m, --memory 512m | deploy.resources.limits.memory | Enforce maximum memory allocation |
| --network my-net | networks: [my-net] | Attach container to custom bridge network |
Docker Run → Compose
Instantly convert raw docker run CLI commands, flags, volumes, and port mappings into production-ready docker-compose.yml files.
Bidirectional Conversion
Seamlessly convert in reverse: paste any docker-compose.yml service definition and generate clean, reproducible docker run commands.
100% Client-Side & Private
All parsing and YAML serialization executes strictly inside your browser. No passwords, tokens, or environment secrets leave your device.
Frequently Asked Questions
How does Docker Run to Docker Compose conversion work?
Does this tool handle named volumes vs host bind mounts?
Can I convert a docker-compose.yml file back to a docker run command?
Are my secrets or environment variables sent to any server?
More Dev Tools Utilities
Cron Generator & Expression Parser
Build, parse, and translate cron expressions visually. Features plain-English interpretation, next execution times (Local & UTC), and multi-platform snippets.
JSON Formatter
Format, beautify, minify, and validate JSON instantly. Adjustable indentation with real-time syntax validation and error feedback.
Markdown Preview
Write Markdown and see rendered HTML in real-time. Split-pane editor with copy Markdown/HTML.