| Flag | Compose key | Example |
|---|---|---|
| --name | container_name | --name myapp |
| -p / --publish | ports | -p 8080:80 |
| -e / --env | environment | -e NODE_ENV=prod |
| -v / --volume | volumes | -v /host:/container |
| --network | networks | --network appnet |
| --restart | restart | --restart unless-stopped |
| --entrypoint | entrypoint | --entrypoint "/bin/sh" |
| -m / --memory | mem_limit | -m 512m |
| --cpus | cpus | --cpus 1.5 |
| -u / --user | user | -u 1000:1000 |
| -w / --workdir | working_dir | -w /app |
| -l / --label | labels | -l app=myapp |
Generated YAML follows the Compose Specification (used by Docker Compose V2+). The legacy version: key is intentionally omitted — it is deprecated and no longer required by modern Docker Desktop and Docker Engine.
Paste a docker run command into the input and select Convert. Read the generated Compose YAML before copying it into your project. The example below names a web service and maps host port 8080 to container port 80. Compare ports, environment variables, mounts, and the image tag with your original command so you can catch a missing flag before starting a container.
This converter parses a supported subset of command syntax; it does not execute Docker or inspect an image. Shell substitutions, unusual quoting, and unsupported flags need manual review. Keep secrets out of a command you plan to share. After saving the YAML locally, validate it with your installed Compose tooling and check the resulting configuration against your deployment environment before bringing the services up.
Input: docker run --name web -p 8080:80 nginx
Output:
services:
web:
image: nginx
container_name: web
ports:
- '8080:80'
docker run commands become hard to manage once they include multiple flags for ports, volumes, environment variables, and networks. A docker-compose.yml is version-controlled, readable, and supports multi-service orchestration with a single 'docker compose up' command.
The converter supports the most common flags: -d/--detach, --name, -p/--publish, -e/--env/--env-file, -v/--volume, --network, --restart, --memory/-m, --cpus, --user, --workdir/-w, --entrypoint, --label/-l, and multi-word commands via CMD. Image and tag are always extracted.
Usually for simple services the generated YAML works as-is. For complex setups you may want to add depends_on, healthcheck, build context, or secrets. The generator creates a minimal, correct starting point that you can extend.
The converter generates modern Compose format without a version: key, following the Compose Specification (used by Docker Compose V2 and later). The version key is deprecated in the latest specification.