elefcode

docker run → docker-compose

Paste a docker run command and get an equivalent compose file.

services:
  webapp:
    image: "nginx:alpine"
    container_name: webapp
    restart: unless-stopped
    ports:
      - "8080:80"
      - "443:443"
    volumes:
      - "/srv/data:/var/www/html"
    environment:
      - "NODE_ENV=production"
      - "API_URL=https://api.example.com"
    networks:
      - backend

networks:
  backend:
    external: true

Supports the common flags: -p, -v, -e, --env-file, --name, --restart, --network, -w, -u, --entrypoint, --cap-add, --device, labels and more. Anything unrecognised is listed under Notes rather than silently dropped.

Advertisement

Guide

About the docker run to Compose Converter

Long docker run commands are painful to maintain — they end up buried in shell history or a README, and every change means re-typing a wall of flags. Moving to Docker Compose makes the same configuration declarative, version-controllable, and easy to bring up with one command.

Paste your command and this tool produces the equivalent docker-compose.ymlservice, translating each flag to its Compose key. Anything it doesn't recognise is reported rather than silently dropped.

How the flags map

  • -p → ports
  • -v → volumes
  • -e → environment
  • --name → container_name
  • --restart → restart
  • --network → networks
  • -w / -u → working_dir / user

Why move to Compose

Compose turns run-time flags into a file you can commit. That means the configuration is reviewable in pull requests, reproducible across machines, and easy to extend when you add a database or cache alongside your app. Starting everything becomes docker compose up -d.

What to check afterwards

A few flags have no direct Compose equivalent or depend on your setup — -d and --rm are run-time behaviours rather than config, and named networks are emitted as external: true on the assumption they already exist. Review the output before running it in production.

How to use it

  1. 1Paste your full docker run command (multi-line with backslashes is fine).
  2. 2Read the generated docker-compose.yml on the right.
  3. 3Check the Notes section for any flags that could not be mapped.
  4. 4Copy or download the file and run docker compose up -d.

Frequently asked questions

Does it handle multi-line commands?

Yes. Backslash line continuations are joined automatically, so you can paste a command exactly as it appears in a README or script.

What happens to flags it does not support?

They are listed under Notes rather than dropped silently, so you know exactly what to add by hand.

Why is my network marked external: true?

A --network flag refers to a network that already exists, so the output assumes it is external. If Compose should create it instead, remove that line.

What about -d and --rm?

Those control how a container is run, not how it is configured, so they have no Compose equivalent. Use docker compose up -d for detached mode.

Is my command sent anywhere?

No. Parsing and YAML generation happen entirely in your browser.

Related tools