Ctrl + K
Developer

Docker Run to Compose

Convert single Docker run commands into clean, readable Docker Compose YAML configuration files.

Docker Run Command 1 lines
Docker Compose YAML 13 lines

All parsing happens locally in your browser. Your commands are never sent to any server.

Migrating from docker run to docker-compose.yml is one of the first steps toward reproducible, version-controlled infrastructure. Our Docker Run to Compose converter parses your existing CLI commands and generates clean, properly structured YAML — no more manual translation of every flag.

Supported Flags

  • Port Mapping

    -p / --publish → ports list

  • Volumes

    -v / --volume → volumes list with named volume detection

  • Environment

    -e / --env → environment variables

  • Networks

    --network → networks with optional aliases

  • Restart Policy

    --restart → restart policy (always, unless-stopped, on-failure)

  • Resource Limits

    --cpus, -m / --memory, --pids-limit

  • Healthcheck

    --health-cmd, --health-interval, --health-retries, --health-timeout

  • Logging

    --log-driver and --log-opt → logging configuration

How to Use the Converter

  1. Paste your docker run command — Enter any valid docker run command into the left panel.
  2. Review the generated YAML — The right panel instantly shows the equivalent docker-compose.yml configuration.
  3. Copy or download — Use the Copy button or download the YAML file for direct use in your project.

Example Conversion

Input

docker run -d \
  --name my-app \
  -p 3000:3000 \
  -v ./data:/app/data \
  -e DB_HOST=localhost \
  -e DB_PORT=5432 \
  --restart always \
  my-app:latest

Output

services:
  my-app:
    image: my-app:latest
    ports:
      - "3000:3000"
    volumes:
      - ./data:/app/data
    environment:
      - DB_HOST=localhost
      - DB_PORT=5432
    restart: always

Key Features

  • Smart Parsing

    Handles quoted strings, escaped characters, and complex flag combinations.

  • Named Volume Detection

    Automatically detects named volumes and adds them to the top-level volumes section.

  • Network Generation

    Generates network definitions with bridge driver and alias support.

  • Clean YAML Output

    Properly indented, production-ready Docker Compose format.

  • One-Click Copy

    Copy the generated YAML to your clipboard instantly.

  • 100% Private

    All parsing is done client-side. No data is uploaded anywhere.

Frequently Asked Questions

What Docker flags are supported?
The converter supports most commonly used flags: port mapping (-p), volumes (-v), environment variables (-e), networks, restart policies, resource limits (--cpus, --memory), healthchecks, logging, labels, capabilities, and more. Flags without a Compose equivalent (like --rm) are omitted.
Does it support multi-line commands?
Yes. The converter accepts commands split across multiple lines with backslash continuations. Just paste the full command as-is.
How are named volumes handled?
Volume sources that don't start with /, ./, or ~ are treated as named volumes and added to the top-level volumes: section with a local driver.
Can I convert commands with subcommands or exec?
This tool is designed specifically for docker run commands. Commands like docker exec, docker build, or docker compose are not supported.

Related Tools