Docker Compose to docker run converter

Paste a Compose file, pick a service, and get the docker run command that starts the same container. Your file stays in this browser.

Stays in your browser. What you paste or choose is read on this page only. It is not sent to a server, not saved in the link or in browser storage, and never part of analytics.

Paste the text, or choose a file from your computer. Up to 512 KiB.

0 of 512 KiB

The other way: docker run to Compose

What it does

It reads a Compose file with the same safe parser as the Compose Analyzer and writes one service as a docker run command, one option per line: ports in short or long syntax, volumes and mounts, environment, networks with aliases and fixed addresses, health check, limits from deploy.resources, logging and more.

How it works

  1. The file is parsed with size, depth and alias limits; no YAML tag or include is followed.
  2. Every value is quoted for a POSIX shell. Compose interpolation such as ${DB_PASSWORD:?} becomes the same shell expansion, so the command reads the variable from your shell, and a literal $$ stays a literal $.
  3. Attributes docker run has no option for (depends_on, build, profiles, most of deploy) are listed as notes, with their line in your file.
  4. Your file is also checked by the Compose Analyzer, the same rules as /tools/compose-analyzer.

Example

A service with a secret from .env, converted:

Input
docker-compose.yml
services:
  db:
    image: postgres:17
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set it in .env}
    ports:
      - "127.0.0.1:5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes:
  pgdata: {}
Output
docker run
docker run -d \
  --restart unless-stopped \
  -e POSTGRES_PASSWORD="${POSTGRES_PASSWORD:?Set it in .env}" \
  -p 127.0.0.1:5432:5432 \
  -v pgdata:/var/lib/postgresql/data \
  postgres:17

Limits

  • One service per command. A file with several services gets a service picker; links between them (depends_on, service names) do not carry over.
  • Compose names volumes and networks after the project (<project>_data); the command uses the plain name unless the file sets name:. Each case is listed.
  • docker run does not read .env: export the variables first. Nothing is run here.
  • build: is not converted: build and tag the image first.

Sources

  1. Docker Docs: Compose file reference
  2. Docker Docs: docker container run
  3. Compose Specification

Updated

Next step

Docker Compose Analyzer

A free public tool by ANAROQ, a company building compute infrastructure. What ANAROQ is building