docker run to compose
ConverterConvert a docker run command into docker-compose.yml with ports, volumes and env vars, so ad-hoc containers become versioned orchestration stacks you can.
docker run command into a docker-compose.yml configuration fileversion: '3.9'
services:
web:
image: nginx:alpine
container_name: web
restart: unless-stopped
networks:
- mynet
ports:
- '8080:80'
- '443:443'
environment:
DB_HOST: db
DB_USER: root
volumes:
- /data:/var/www
Related Tools
About docker run to compose
A long, unmemorable docker run command stuffed with -p, -v, -e, and other flags has to be retyped on every new machine. This tool parses a docker run command and converts it into a clean docker-compose.yml locally in your browser, mapping ports, volumes, environment variables, networks, and more into structured fields for version control and reuse.
How to Use
- Open the docker run to compose tool
- Select the source and target formats
- Adjust the output options as needed
- Click the Convert button; results appear in real time
- Copy or export the result
Use Cases
- Lock down deploys — Turn an ad-hoc docker run into a compose file and commit it for version control.
- Move environments — Convert a dev-machine run command to compose to reproduce it in test or production.
- Untangle flags — Structure stacked CLI flags to clearly see port, volume, and env mappings.
- Multi-container — Convert several separate run commands into compose services managed together.
- Document setup — Turn a word-of-mouth start command into readable YAML for your deploy docs.
- CI integration — Translate a docker run from a CI pipeline step into a compose service for local reproduction.
- Share with team — Convert a personal run command into a checked-in compose file so everyone runs the same stack.
FAQ
Which docker run flags are supported?
Common ones — -p ports, -v volumes, -e env vars, --name, --network, --restart, -d — are recognized and mapped to the matching compose fields. Rare or very new flags may need manual addition.
Which compose version is produced?
It usually outputs a broadly compatible v3 structure. You can tweak the version field for your Docker setup, or drop it to use the Compose spec default behavior.
How are multiple -e env vars handled?
Each -e becomes an item in the environment list; if a value contains equals signs or spaces, ensure the original command quoted it properly — the tool preserves it as-is.
Can it convert compose back to run?
It currently does one-way run-to-compose only. Reverse conversion involves splitting multiple services and is complex, so it is not supported.
Can I run docker compose up right away?
Usually yes, but read through the generated YAML first to confirm volume paths, image tags, and network names match your target environment before starting.