Docker Run to Compose

Runs in browser

Convert 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: 512m
Supported docker run flags ▾
FlagDescription
-p / --publishMaps container port to host port. Format: host:container
-v / --volumeMounts host path or named volume into container
-e / --envSets environment variable inside container
--env-fileLoads environment variables from a file
--nameAssigns a name to the container
--networkConnects container to a network
--restartRestart policy: no / always / unless-stopped / on-failure
--memoryMemory limit (e.g. 512m, 1g)
--cpusCPU limit (e.g. 0.5 = half a CPU)
-w / --workdirSets the working directory inside the container
-u / --userSets the user to run the container as
--hostnameSets the container hostname
--labelAdds metadata label to the container
--entrypointOverrides the default entrypoint of the image
-dDetached mode — runs container in background (ignored in Compose)
image:tagThe 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

  1. Paste your docker run command

    Paste any docker run command in the left panel. Multi-line commands with \ continuation are supported.

  2. Review the Compose YAML

    The right panel shows the generated docker-compose.yml with all parsed flags.

  3. Copy or download

    Click Copy or Download to save the docker-compose.yml file.

Common use cases

  • Migrating docker run scripts to ComposeConvert ad-hoc docker run commands from documentation or shell scripts into a versioned docker-compose.yml for easier management.
  • Setting up multi-container servicesTranslate 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.

    Input
    docker run -d --name nginx -p 80:80 -v /data:/usr/share/nginx/html nginx:latest
    Output
    services:
      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.

You might find these useful too.

More api tools