Docker Run to Compose
Convert docker run commands to docker-compose.yml instantly. Supports ports, volumes, environment variables, networks, restart policies, and more.
How to Use
- Paste your docker run command into the left panel (or click Example).
- Click Convert.
- Review the generated docker-compose.yml in the right panel.
- Click Copy and save it as
docker-compose.ymlin your project.
Supported Flags
—name NAME— Service name-p / —publish HOST:CONTAINER— Port mappings-v / —volume HOST:CONTAINER[:mode]— Volume mounts-e / —env KEY=VALUE— Environment variables—network NETWORK— Network—restart POLICY— Restart policy (no, always, unless-stopped, on-failure)—cap-add CAP— Capability additions—memory MEM— Memory limit (e.g. 512m, 1g)—cpus N— CPU limit
Common Use Cases
- Migration: Turn one-off docker run commands into reproducible compose configurations.
- Documentation: Convert run commands from README files or docs into compose format for your team.
- Multi-service setup: Generate individual service blocks and combine them into a single compose file.
- CI/CD: Replace fragile shell scripts of docker run commands with a declarative compose file.
FAQ
What docker run flags are supported?
The converter supports: --name, -p/--publish (ports), -v/--volume (volumes), -e/--env (environment variables), --network, --restart, -d (detach), --cap-add, --memory, --cpus, plus the image name and optional command.
What compose file version is generated?
The converter generates docker-compose.yml using version 3.8 format, which is widely compatible with recent versions of Docker Compose (both the legacy docker-compose CLI and the newer docker compose plugin).
How is the service name derived?
If you use --name in your docker run command, that value is used as the service name. Otherwise, the service name is derived from the image name by stripping the registry prefix and tag, and replacing slashes with underscores.
Does it support multi-line docker run commands?
Yes. Paste commands with backslash line continuations and the converter handles them correctly.
What about flags not listed above?
Unsupported flags are silently ignored. The converter focuses on the most common flags used in docker run commands. You may need to manually add advanced options like --security-opt or --device to the generated compose file.