General dev

Docker Run to Compose Converter

Runs locally

Use Docker Run to Compose Converter

What it does

Turn a docker run one-liner into a docker-compose.yml service with the same image, ports, volumes, environment and restart policy.

It runs entirely in your browser: nothing you enter is uploaded.

Example

nginx container

Input
docker run -d --name web -p 8080:80 -v ./site:/usr/share/nginx/html:ro -e TZ=UTC --restart unless-stopped nginx:1.27
Output (captured 2026-10-20)
services:
  web:
    image: nginx:1.27
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./site:/usr/share/nginx/html:ro
    environment:
      - TZ=UTC

A web service with image nginx:1.27, restart: unless-stopped, port "8080:80", the read-only volume and TZ=UTC under environment.

FAQ

Which docker run options are converted?

-p/--publish, -v/--volume, -e/--env, --name, --restart and --network/--net (a network is also declared as external), with a space or = before the value; -d, -i, -t, -it and --rm are skipped. Every other flag, such as -w, --memory, --env-file or the attached form -p8080:80, is dropped without a warning.

Why is the image name wrong?

The converter takes the last word that is not an option as the image, so a command after the image replaces it: docker run alpine:3.20 echo hello gives image: hello. Remove the trailing command and add it as command: in the YAML yourself.

Is my command uploaded?

No. Parsing runs in your browser and nothing is sent anywhere, so secrets passed with -e stay on your machine.