Docker Run to Compose
Runs in browserConvert docker run commands to docker-compose.yml YAML instantly.
Convert docker run commands to Docker Compose YAML instantly. Paste any docker run command and get a ready-to-use docker-compose.yml. Supports ports, volumes, environment variables, networks, restart policies and more.
Docker Run to Compose tool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
services:
my-app:
image: myapp:latest
container_name: my-app
ports:
- "3000:3000"
- "443:443"
volumes:
- /data/app:/app/data
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://localhost/mydb
restart: unless-stopped
mem_limit: 512mSupported docker run flags ▾▼
| Flag | Description |
|---|---|
-p / --publish | Maps container port to host port. Format: host:container |
-v / --volume | Mounts host path or named volume into container |
-e / --env | Sets environment variable inside container |
--env-file | Loads environment variables from a file |
--name | Assigns a name to the container |
--network | Connects container to a network |
--restart | Restart policy: no / always / unless-stopped / on-failure |
--memory | Memory limit (e.g. 512m, 1g) |
--cpus | CPU limit (e.g. 0.5 = half a CPU) |
-w / --workdir | Sets the working directory inside the container |
-u / --user | Sets the user to run the container as |
--hostname | Sets the container hostname |
--label | Adds metadata label to the container |
--entrypoint | Overrides the default entrypoint of the image |
-d | Detached mode — runs container in background (ignored in Compose) |
image:tag | The Docker image to use (name:version) |
[command] | Command to run inside the container |
🔒 Runs in your browser · No uploads · Your data never leaves your device
How to use
Paste your docker run command
Paste any docker run command in the left panel. Multi-line commands with \ continuation are supported.
Review the Compose YAML
The right panel shows the generated docker-compose.yml with all parsed flags.
Copy or download
Click Copy or Download to save the docker-compose.yml file.
Common use cases
- Migrating docker run scripts to Compose — Convert ad-hoc docker run commands from documentation or shell scripts into a versioned docker-compose.yml for easier management.
- Setting up multi-container services — Translate a complex docker run command with ports, volumes, and env vars into a compose service definition as a starting point.
Examples
Nginx with port and volume
docker run with port mapping and volume.
Inputdocker run -d --name nginx -p 80:80 -v /data:/usr/share/nginx/html nginx:latestOutputservices: nginx: image: nginx:latest container_name: nginx ports: - "80:80" volumes: - /data:/usr/share/nginx/html
Frequently asked questions
- Are all docker run flags supported?
- The most common flags are supported: -p, -v, -e, --env-file, --name, --network, --restart, --memory, --cpus, -w, -u, --hostname, --label, --entrypoint. Flags like --rm and -d are ignored as they don't map to Compose.
- Can I paste multi-line commands?
- Yes. Commands with backslash line continuation are handled correctly.
Key concepts
- Docker Compose
- A tool for defining and running multi-container Docker applications using a YAML file (docker-compose.yml) to specify services, networks, and volumes.
- Service
- A named container definition in Docker Compose — equivalent to a docker run command expressed in YAML format.
Related tools
You might find these useful too.