Docker Run to Compose
Convert Docker run commands to Docker Compose YAML format.
Need to check your Docker Compose version? Run this command:
docker compose versionAbout Docker Run to Compose Converter
What Does This Tool Do?
This tool converts docker run commands into Docker Compose YAML format. Instead of maintaining long, complex docker run commands with dozens of flags, you can convert them into a clean, readable docker-compose.yml file that is easier to version control, share with your team, and maintain over time.
Why We Built It
Docker run commands tend to grow unwieldy as you add ports, volumes, environment variables, restart policies, and resource limits. A 200-character docker run command is hard to read, debug, and reproduce. Docker Compose provides a declarative alternative that is self-documenting, version-controllable, and much easier to modify.
How to Use It
Paste your docker run command in the left panel. The tool parses all flags and options and generates equivalent Docker Compose YAML. You can select the Compose file version, adjust indentation, and copy or download the output. Multi-line commands with backslash continuation are fully supported.
Benefits of Docker Compose Over docker run
Docker Compose files are declarative and self-documenting, making it clear what configuration a service needs. They support multi-container applications with service dependencies, shared networks, and volume definitions. Compose files can be version-controlled in Git, shared across teams, and used consistently across development, staging, and production environments.
Supported Flags
The converter supports all common docker run flags including -p (ports), -v (volumes), -e (environment variables), --name (container name), --restart (restart policy), --network, -w (working directory), --entrypoint, --memory, --cpus, --privileged, --user, --hostname, --dns, --add-host, --cap-add, --cap-drop, --device, --log-driver, and many more.