๐Ÿ”’ Runs in your browser โ€” nothing is uploadedโœ“ Free, no signup

Docker Run to Docker Compose

Paste one or more docker run commands to get an equivalent docker-compose.yml โ€” ports, volumes, environment variables, networks and restart policies included.

0 characters

docker-compose.yml

Loading...

When should you use the Docker Run to Compose?

  • Turning a docker run command from a README into a Compose file
  • Combining several containers into one docker-compose.yml
  • Making container setups easier to version and share

How to use the Docker Run to Compose

  1. 1

    Paste commands

    Paste one or more docker run commands. Line continuations (\) are fine.

  2. 2

    Check the YAML

    Each command becomes a service. Named volumes and networks are declared at the bottom.

  3. 3

    Review notes

    Any option that couldn't be converted is listed under the output.

  4. 4

    Save it

    Download docker-compose.yml and run docker compose up -d.

Examples

nginx with a port and volume

docker run

docker run -d --name web -p 8080:80 -v ./html:/usr/share/nginx/html --restart always nginx

docker-compose.yml

services:
  web:
    image: nginx
    container_name: web
    restart: always
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html

Common errors and how to fix them

Paste a command that starts with docker run
Remove anything before docker, such as a $ prompt. sudo docker run is fine.
A network is marked external
Networks created with docker network create are external to Compose. Remove external: true if you want Compose to create it.
Related tools:ย .env Parser ยท YAML Formatter ยท cURL to Code

More from Code Formatters & Minifiers

Free tools that run in your browser โ€” no signup, nothing uploaded.

Docker Run to Compose FAQ

Ports (-p), volumes (-v, --mount), environment (-e, --env-file), --name, --restart, --network, -w, -u, --entrypoint, labels, healthchecks, logging, capabilities, devices, ulimits, --gpus, -it and more. Unsupported options are listed under the output.

No. Modern Docker Compose ignores it. Tick the option only if you use an older docker-compose that needs version: "3.8".

Yes โ€” paste multiple commands, one per line or joined with &&. Each becomes its own service in the same file.

They're dropped: Compose runs services detached with docker compose up -d, and manages container removal itself.

A volume like pgdata:/var/lib/postgresql/data is added to the service and declared in a top-level volumes section.

No. Everything runs in your browser, so your commands never leaves your device.