DEV Community

Rashid Salimov
Rashid Salimov

Posted on Originally published at vault-pro.rashid-salimov96.workers.dev

Docker Run to Docker Compose: Stop Converting Commands by Hand

When setting up self-hosted services, testing open-source projects, or copying quick commands from GitHub READMEs, documentation almost always gives you a docker run one-liner:

docker run -d \
  --name postgres_db \
  -p 5432:5432 \
  -v pgdata:/var/lib/postgresql/data \
  -e POSTGRES_PASSWORD=supersecret \
  -e POSTGRES_USER=admin \
  --restart unless-stopped \
  postgres:16-alpine
Enter fullscreen mode Exit fullscreen mode

While great for testing, running containers via individual commands is difficult to maintain in production. You forget which flags you passed, configurations aren't tracked in version control, and restarting a machine requires hunting through your bash history.

The standard fix is writing a docker-compose.yml file. But formatting YAML manually is tedious: one missing space breaks the whole file.

The Client-Side Solution: Docker Run to Compose Converter

The Docker Run to Docker Compose Converter lets you paste one or multiple docker run commands and instantly outputs clean, valid Docker Compose specification YAML.

Everything runs 100% in your browser — zero tracking, zero server uploads.


Key Capabilities

  1. Multi-Container Support:
    Paste several docker run commands in a single input. The parser extracts container names and consolidates them into a single services: block under one docker-compose.yml.

  2. Full Flag Parsing:

    • Ports: -p 8080:80 → ports: ["8080:80"]
    • Volumes: -v /host/path:/container/path:ro → volumes: block + automatic root volumes: declaration for named volumes
    • Environment: -e KEY=value or --env-file → formatted environment: dictionary
    • Networks: --network app-net → networks: section
    • Restart Policies: --restart always or --restart unless-stopped
    • Resource Limits: --memory 512m and --cpus 1.5
  3. Output Example:

version: '3.8'

services:
  postgres_db:
    image: postgres:16-alpine
    container_name: postgres_db
    restart: unless-stopped
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: supersecret
      POSTGRES_USER: admin
    volumes:
      - pgdata:/var/lib/postgresql/data

volumes:
  pgdata:
Enter fullscreen mode Exit fullscreen mode

Privacy First

Unlike common web conversion tools that log inputs on a backend, this tool is part of Digital Vault PRO — an open collection of client-side developer utilities where all calculations execute locally in the browser.

Convert your commands securely: Docker Run to Compose Converter.

Top comments (0)