All Apps

Docker Run to Docker Compose Converter

Client-SideOffline ReadyDev ToolsNo login required

Convert docker run CLI commands to production-ready docker-compose.yml files and reverse Compose YAML to docker run commands.

Conversion Mode:
Load Preset:
Supports multi-line commands with \ continuations, quotes, and complex flags.238 chars
Compose Format:
version: '3.8'
services:
  postgres-db:
    container_name: postgres-db
    image: postgres:16-alpine
    restart: unless-stopped
    ports:
      - '5432:5432'
    volumes:
      - pgdata:/var/lib/postgresql/data
    environment:
      - POSTGRES_USER=admin
      - POSTGRES_PASSWORD=supersecret
      - POSTGRES_DB=production
volumes:
  pgdata: null
Imagepostgres:16-alpine
Ports1
Volumes1
Env Vars3

Common Docker Run Flags & Compose Mapping

Docker CLI FlagDocker Compose AttributeDescription
-p, --publish 8080:80ports: ["8080:80"]Map host port to container port
-v, --volume /host:/data:rovolumes: ["/host:/data:ro"]Mount directory or named volume
-e, --env KEY=valenvironment: [KEY=val]Inject runtime environment variables
--restart unless-stoppedrestart: unless-stoppedContainer lifecycle restart behavior
-m, --memory 512mdeploy.resources.limits.memoryEnforce maximum memory allocation
--network my-netnetworks: [my-net]Attach container to custom bridge network

Docker Run → Compose

Instantly convert raw docker run CLI commands, flags, volumes, and port mappings into production-ready docker-compose.yml files.

Bidirectional Conversion

Seamlessly convert in reverse: paste any docker-compose.yml service definition and generate clean, reproducible docker run commands.

100% Client-Side & Private

All parsing and YAML serialization executes strictly inside your browser. No passwords, tokens, or environment secrets leave your device.

Frequently Asked Questions

How does Docker Run to Docker Compose conversion work?
The tool parses command line arguments and flags (like -p, -v, -e, --restart, --name, and --network) using an AST tokenizer, mapping them accurately to the official Docker Compose Specification format.
Does this tool handle named volumes vs host bind mounts?
Yes. Relative or absolute host paths (e.g. ./data:/app or /var/log:/log) are preserved as bind mounts, while named volumes (e.g. pgdata:/var/lib/postgresql/data) are automatically declared under the top-level volumes section in the generated YAML.
Can I convert a docker-compose.yml file back to a docker run command?
Yes! Switch to "Compose → Docker Run" mode, paste your service YAML, and the converter will generate a clean multi-line docker run CLI command with all corresponding flags and environment variables.
Are my secrets or environment variables sent to any server?
No. 100% of parsing and YAML generation runs locally in your browser JavaScript memory. No tokens, passwords, database URLs, or configurations are ever sent across the network.
Recommended For You

More Dev Tools Utilities

View all Dev Tools tools