Docker Run to Compose converter. Instantly convert docker run CLI commands to docker-compose.yml with ports, volumes, environment variables, and more. 100% browser-based.
100% browser-based — your data never leaves your device
Convert docker run commands to docker-compose.yml format instantly.
version: '3'
services: myapp:
image: nginx:alpine
ports: - '8080:80'
volumes: - './html:/usr/share/nginx/html'Send HTTP requests (GET, POST, PUT, DELETE) and inspect responses from your browser.
WebSocket TesterConnect to WebSocket endpoints, send messages, and inspect frames.
HTTP Status Code ReferenceSearchable reference of all HTTP status codes with descriptions and use cases.
Request BuilderBuild HTTP requests interactively and generate code snippets in multiple languages.
curl to Fetch ConverterConvert curl commands to JavaScript fetch, Python requests, and more.
OpenAPI ValidatorValidate OpenAPI 3.x and Swagger 2.0 specifications for correctness.
Mock API GeneratorGenerate mock API responses from JSON schemas for rapid development.
Docker → ComposeConvert docker run commands to docker-compose.yml format instantly.
Fake Data GeneratorGenerate realistic fake data including names, emails, phone numbers, addresses, and more.
Docker run commands are great for one-off launches and terrible as a record of how a service should run. This converter translates a docker run command into a docker-compose.yml service so your setup becomes readable, shareable, and version-controlled. The conversion is live, which makes iteration painless:
The most common situation is migration: your local development workflow grew a collection of docker run commands, often stored in README snippets or shell history, and you want the same services managed through a single docker-compose.yml. The converter maps common flags to their compose equivalents — the publish flag to ports, the volume flag to volumes, the environment flag to env entries, plus networks, restart policies, and healthchecks — so each command becomes a proper service definition without you translating syntax by hand.
It is equally handy for pulling one-off commands out of documentation. Blogs and READMEs love showing docker run invocations, and when you want to keep using that service, converting it to compose gives you a persistent, reproducible definition. Teams standardizing local environments benefit too: compose files live in version control, so every developer runs the same services with the same options. If you run multiple containers, convert each command separately and combine the resulting services into one file.
Docker run commands often carry secrets. Environment variables set with the -e flag routinely hold database passwords, API tokens, and connection strings, and a command you paste for conversion may expose them in plain text. If that command were sent to a remote converter, those credentials would be transmitted as part of the request. This tool parses everything locally in your browser, so your commands are never transmitted or stored.
That matters when you convert real startup commands rather than scrubbed examples. Pasting an authentic command with its actual environment variables means the resulting compose file is correct the first time, and doing it locally means no third party ever sees the credentials embedded in your setup.
Copy your docker run CLI command and paste it into the input area above.
The docker-compose.yml output updates in real-time as you type. Ports, volumes, environment variables, and all flags are mapped to compose format.
Click Copy to grab the compose YAML, or download it as a .yml file for use in your project.
Practical examples to help you get the most out of Docker → Compose:
# docker run -d --name myapp -p 8080:80 -v ./html:/usr/share/nginx/html nginx:alpine
# Becomes:
version: '3'
services:
myapp:
image: nginx:alpine
ports:
- '8080:80'
volumes:
- './html:/usr/share/nginx/html'# docker run -d --name api -p 3000:3000 -e NODE_ENV=production -e DB_URL=postgres://localhost/mydb --restart unless-stopped node:18
# Becomes:
version: '3'
services:
api:
image: node:18
ports:
- '3000:3000'
environment:
NODE_ENV: production
DB_URL: postgres://localhost/mydb
restart: unless-stoppedThe --link flag is a legacy Docker feature. In docker-compose, services can reach each other by service name on the same network. Use networks instead of --link.
Without --name, the compose file uses a generated service name. Always use --name to give your container a predictable service name in the compose output.
It supports all commonly used flags including -p, -v, -e, --name, --restart, --network, -d, -it, --rm, --memory, --cpus, --env-file, -w, -u, --entrypoint, --label, --expose, --add-host, --platform, --health-cmd, and more.
Docker run -p 8080:80 becomes ports: ['8080:80'] in compose. Multiple -p flags produce multiple port entries.
Docker run -v ./data:/app/data becomes volumes: ['./data:/app/data']. Named volumes, bind mounts, and volume drivers are all preserved.
Yes. Both -e VAR=value and -e VAR (without value, using host env) are supported. --env-file is mapped to env_file in compose.
No. All parsing and conversion happens locally in your browser. Your commands are never transmitted or stored.
This tool converts a single docker run command to a single service in docker-compose.yml. For multi-container setups, convert each command separately and combine the services.
The generated compose file uses version 3 syntax which is compatible with modern Docker Compose (v2) and Docker Swarm.
Maps all common docker run flags to compose equivalents: ports (-p), volumes (-v), env (-e), networks, restart policies, healthchecks, and more.
See the compose YAML update live as you edit the docker run command — no button clicking needed.
Invalid docker run commands are flagged with clear error messages so you can fix and retry.
All parsing happens locally in your browser. Your docker commands never leave your device.
Docker Run to Compose Converter is useful in a variety of scenarios across different workflows:
Migrating docker run based development setups to docker-compose.yml
Converting one-off docker run commands from documentation to reusable compose files
Standardizing local development environments with version-controlled compose files
The --name flag becomes the service name in compose. Without it, the service name is derived from the image name. Always use --name for clarity.
The --restart flag maps to the restart policy in compose. 'unless-stopped', 'always', 'on-failure', and 'no' are all supported.
Explore more tools in the API workspace:
REST API Client
Send HTTP requests (GET, POST, PUT, DELETE) and inspect responses from your browser.
WebSocket Tester
Connect to WebSocket endpoints, send messages, and inspect frames.
HTTP Status Code Reference
Searchable reference of all HTTP status codes with descriptions and use cases.
Request Builder
Build HTTP requests interactively and generate code snippets in multiple languages.
curl to Fetch Converter
Convert curl commands to JavaScript fetch, Python requests, and more.
OpenAPI Validator
Validate OpenAPI 3.x and Swagger 2.0 specifications for correctness.