DevTulz Online

Docker Run to Compose Converter

docker run command
docker-compose.yml
Examples:

What is Docker Compose?

Docker Compose is a tool for defining and running multi-container Docker applications using a declarative YAML file (docker-compose.yml). Instead of executing long docker run commands with many flags every time you start a container, you describe the configuration once in a file and launch everything with docker compose up. This makes container configurations reproducible, version-controllable in Git, and easy to share with teammates. Running databases, caches, web servers, and background workers together becomes a one-command operation. This converter translates docker run flags into their docker-compose.yml equivalents: -p becomes ports, -e becomes environment, -v becomes volumes, --restart becomes restart, --name becomes the service name, --network becomes networks, and resource limits (--memory, --cpus) become the deploy.resources section.

How to Use Docker Run to Compose

  • Paste your full docker run command (including the 'docker run' prefix) into the input box.

  • The docker-compose.yml output is generated instantly as you type.

  • Click any of the example buttons to load common use cases like Nginx, PostgreSQL, or Redis.

  • Review the generated YAML β€” named networks are output with 'external: true' as a starting point.

  • Adjust the service name and version fields as needed.

  • Click Copy to copy the YAML and save it as docker-compose.yml in your project.