Skip to content
ToolMug

docker run to Docker Compose

Paste one or more docker run commands to get the equivalent compose.yaml. Ports, volumes, environment variables, networks, restart policy, memory and CPU limits, logging and health checks are converted, and any flags that can't be are listed so you can add them by hand.

Runs in your browser — nothing you enter is uploaded

docker run → Docker Compose
docker run
Docker Compose

How to use

  1. Paste docker run commands on the left. Multi-line commands with trailing backslashes work; separate several commands with new lines, semicolons or &&.
  2. The Compose file appears on the right. Each command becomes a service named after --name, or after the image if there is none.
  3. Check the yellow note for anything not converted, then copy or download compose.yaml and run docker compose up -d.

Options explained

Supported flags
-p, -v, --mount, -e, --env-file, --name, --restart, --network, -w, -u, -h, --entrypoint, -l, --add-host, --dns, --cap-add/drop, --device, -m, --cpus, --shm-size, --ulimit, --log-driver/--log-opt, --health-*, -i, -t, --privileged, --init, --read-only and more.
Named volumes and networks
Named volumes (such as pgdata:/data) are declared under top-level volumes. Custom networks are declared as external true, meaning an existing network is used. The host and none networks become network_mode.
Ports
Port mappings are always quoted. YAML 1.1 reads values like 22:22 as base-60 numbers, and the Docker docs recommend writing ports as strings.
Ignored flags
-d and --rm have no Compose equivalent and are dropped. Unsupported flags such as --gpus are listed in the note.

Example

docker run -d --name web --restart unless-stopped -p 8080:80 \
  -v ./html:/usr/share/nginx/html:ro -e TZ=Asia/Shanghai --memory 512m nginx:1.27

becomes:

services:
  web:
    image: nginx:1.27
    container_name: web
    restart: unless-stopped
    mem_limit: 512m
    ports:
      - "8080:80"
    environment:
      - TZ=Asia/Shanghai
    volumes:
      - ./html:/usr/share/nginx/html:ro

Frequently asked questions

Does the file need a version line?

No. Current Docker Compose (v2) no longer uses the top-level version field; if present it is ignored with a warning.

Are passwords in my environment variables uploaded?

No. Parsing and conversion run in your browser and nothing is sent to a server.

Does it handle quoted arguments?

Yes. Single quotes, double quotes and backslash escapes follow shell rules, so -e "MSG=hello world" keeps the whole value.

Privacy

This tool runs entirely in your browser. Your files and text are processed on your device and are never uploaded to our servers.

Related tools