docker run to compose

Converter

Convert a docker run command into docker-compose.yml with ports, volumes and env vars, so ad-hoc containers become versioned orchestration stacks you can.

Convert a docker run command into a docker-compose.yml configuration file
Converted
CLIDOCKER RUN COMMAND
YMLDOCKER-COMPOSE.YML
version: '3.9'
services:
  web:
    image: nginx:alpine
    container_name: web
    restart: unless-stopped
    networks:
      - mynet
    ports:
      - '8080:80'
      - '443:443'
    environment:
      DB_HOST: db
      DB_USER: root
    volumes:
      - /data:/var/www

About docker run to compose

A long, unmemorable docker run command stuffed with -p, -v, -e, and other flags has to be retyped on every new machine. This tool parses a docker run command and converts it into a clean docker-compose.yml locally in your browser, mapping ports, volumes, environment variables, networks, and more into structured fields for version control and reuse.

How to Use

  1. Open the docker run to compose tool
  2. Select the source and target formats
  3. Adjust the output options as needed
  4. Click the Convert button; results appear in real time
  5. Copy or export the result

Use Cases

  • Lock down deploys — Turn an ad-hoc docker run into a compose file and commit it for version control.
  • Move environments — Convert a dev-machine run command to compose to reproduce it in test or production.
  • Untangle flags — Structure stacked CLI flags to clearly see port, volume, and env mappings.
  • Multi-container — Convert several separate run commands into compose services managed together.
  • Document setup — Turn a word-of-mouth start command into readable YAML for your deploy docs.
  • CI integration — Translate a docker run from a CI pipeline step into a compose service for local reproduction.
  • Share with team — Convert a personal run command into a checked-in compose file so everyone runs the same stack.

FAQ

Which docker run flags are supported?

Common ones — -p ports, -v volumes, -e env vars, --name, --network, --restart, -d — are recognized and mapped to the matching compose fields. Rare or very new flags may need manual addition.

Which compose version is produced?

It usually outputs a broadly compatible v3 structure. You can tweak the version field for your Docker setup, or drop it to use the Compose spec default behavior.

How are multiple -e env vars handled?

Each -e becomes an item in the environment list; if a value contains equals signs or spaces, ensure the original command quoted it properly — the tool preserves it as-is.

Can it convert compose back to run?

It currently does one-way run-to-compose only. Reverse conversion involves splitting multiple services and is complex, so it is not supported.

Can I run docker compose up right away?

Usually yes, but read through the generated YAML first to confirm volume paths, image tags, and network names match your target environment before starting.

Advertisement