Developer / Docker
docker run to Docker Compose Converter
Convert docker run commands into a compose.yaml file, ports, volumes, environment, networks, restart policy, health checks, GPUs, and more, or a Compose service back into docker run; options without an equivalent are listed.
docker run to Docker Compose Converter: The command is split the way a shell would, with quotes and escapes, and each option is mapped to its Compose key: -p to ports, -v and --mount to volumes, -e to environment, --restart, --network, --health-cmd to healthcheck, --gpus to a device reservation, and about forty more. Named volumes and networks get their top-level entries. Several commands become several services in one file. Options with no Compose equivalent are listed instead of being dropped without a word. Runs 100% locally in your browser with zero server file uploads.
- Category
- Developer tools
- Runs
- In your browser
- Cost
- Free · no sign-up
- Availability
- Ready to use
Runs entirely in your browser
compose.yaml
services:
db:
image: postgres:16
container_name: db
environment:
- POSTGRES_PASSWORD=change-me
volumes:
- pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
restart: unless-stopped
volumes:
pgdata:
After converting
Run docker compose config to check the file and see it with defaults filled in, then docker compose up -d to start it. Pin image versions, such as postgres:16 rather than latest, so that a restart does not upgrade the database by surprise.
To read the file in another format, convert it with YAML to JSON; for scheduled jobs in the containers, the cron explainer reads cron expressions.
Volumes and data
A named volume, such as pgdata, is managed by Docker and survives docker compose down; a path such as ./data is a folder on the host. Back up named volumes before removing them with docker compose down -v, which deletes them.
How to use it
- Paste one or more docker run commands; line continuations with a backslash are fine.
- Read the compose.yaml, and any options that could not be converted.
- Copy or download it, or switch direction to turn a Compose file into docker run commands.
Privacy & limitations
Everything runs in your browser; your commands, which may contain passwords, are not uploaded.
Related tools
Frequently asked questions
Why use Compose instead of docker run?
A Compose file records the whole setup in one place that can be read, versioned, and started with docker compose up, instead of long commands kept in shell history. It also starts several containers together with their networks and volumes.
What happens to --rm and -d?
Compose has no --rm: containers are removed with docker compose down. -d is chosen when you run docker compose up -d, so it is not part of the file.
Why are networks marked external?
docker run --network uses a network that already exists, so the converted file refers to it the same way. Remove external: true if you want Compose to create the network itself.
Should I keep passwords in the file?
Prefer an env_file kept out of version control, or Docker secrets, for passwords and keys. The converter keeps what the command had, so review the environment section before committing it.
Free tool · runs in your browser · no account required