Skip to main content

rawops.dev

Skip to tool content

Docker Run ↔ Compose

Paste a docker run command and get an equivalent docker-compose.yml. 100% client-side — nothing leaves your browser.

docker run command
docker run -d --name my-app -p 8080:80 my-image:latest

Quick Recipes

Click a recipe to load a common docker run command and see its compose equivalent.

Docker Run to Docker Compose — Migration Guide

Docker Compose is the standard way to define and run multi-container Docker applications. While docker run is great for quick one-off containers, production deployments benefit from the declarative, version-controlled nature of docker-compose.yml files.

Why Migrate from docker run to Compose?

  • Reproducibility — compose files are declarative and version-controlled
  • Multi-service orchestration — define networks, volumes, and dependencies between containers
  • Easier managementdocker compose up/down manages the full stack
  • Environment parity — same file works in dev, staging, and production
  • Documentation — the compose file documents your infrastructure

docker run vs docker-compose.yml

docker run flagCompose equivalentExample
--namecontainer_namecontainer_name: my-app
-p 8080:80ports- "8080:80"
-v ./data:/appvolumes- ./data:/app
-e KEY=valenvironment- KEY=val
--restart unless-stoppedrestartrestart: unless-stopped
--network my-netnetworksnetworks: [my-net]
--privilegedprivilegedprivileged: true
--cpus / --memorydeploy.resources.limitscpus: "0.5", memory: 512M
--gpus alldeploy.resources.reservationsdevices: [nvidia, gpu]

Supported Flags

This converter supports 40+ docker run flags including ports (-p), volumes (-v, --mount), environment variables (-e, --env-file), networking (--network, --dns), security (--privileged, --cap-add/drop, --security-opt), resources (--cpus, --memory, --gpus), healthchecks, logging, labels, ulimits, sysctls, and more. Multi-line commands with backslash continuation are supported. Unrecognized flags are reported as warnings.

Need to create the Dockerfile itself? Use our Dockerfile Generator to build production-ready, multi-stage Dockerfiles with security hardening and best-practice validation.

Privacy First

All parsing happens entirely in your browser using JavaScript. Your docker run commands, environment variables, passwords, and configuration are never sent to any server. This tool has zero backend dependencies.

Related Tools & Resources