Docker Compose Generator & docker run Converter

Build a stack or paste a docker run command to get a ready-to-edit compose.yaml.

Quick-add services

Active services

compose.yaml

.env.example

Config Health Check

    6 Production-Ready Docker Compose Templates

    Set the required environment variables, check host paths and ports, then run docker compose config before starting a stack.

    Nginx Reverse Proxy

    Supply ./nginx.conf with your upstream targets. Configure TLS and mount the certificates if you serve HTTPS on 443.

    name: "nginx-proxy"
    services:
      nginx:
        image: "nginx:1.27-alpine"
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - "./nginx.conf:/etc/nginx/nginx.conf:ro"
        restart: "unless-stopped"
        networks:
          - "app-net"
    networks:
      app-net: {}
    

    PostgreSQL + Redis

    Persist both stores and reach them from the host over loopback. Set POSTGRES_PASSWORD before starting.

    name: "postgres-redis"
    services:
      postgres:
        image: "postgres:17-alpine"
        ports:
          - "127.0.0.1:5432:5432"
        environment:
          POSTGRES_USER: "app"
          POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
          POSTGRES_DB: "app"
        volumes:
          - "pg_data:/var/lib/postgresql/data"
        healthcheck:
          test:
            - "CMD-SHELL"
            - "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""
          interval: "10s"
          timeout: "5s"
          retries: 5
        restart: "unless-stopped"
        networks:
          - "app-net"
      redis:
        image: "redis:7.4-alpine"
        ports:
          - "127.0.0.1:6379:6379"
        volumes:
          - "redis_data:/data"
        command:
          - "redis-server"
          - "--appendonly"
          - "yes"
        restart: "unless-stopped"
        networks:
          - "app-net"
    volumes:
      pg_data: {}
      redis_data: {}
    networks:
      app-net: {}
    

    Ollama + Open WebUI

    Open the UI on port 3000. Ollama is reachable by service name inside the stack and over loopback on the host.

    name: "ollama-webui"
    services:
      ollama:
        image: "ollama/ollama:0.6.5"
        ports:
          - "127.0.0.1:11434:11434"
        volumes:
          - "ollama_data:/root/.ollama"
        restart: "unless-stopped"
        networks:
          - "app-net"
      open-webui:
        image: "ghcr.io/open-webui/open-webui:v0.6.5"
        ports:
          - "3000:8080"
        environment:
          OLLAMA_BASE_URL: "http://ollama:11434"
        volumes:
          - "open_webui_data:/app/backend/data"
        restart: "unless-stopped"
        networks:
          - "app-net"
    volumes:
      ollama_data: {}
      open_webui_data: {}
    networks:
      app-net: {}
    

    n8n Self-Hosted

    Set and back up N8N_ENCRYPTION_KEY. Use an HTTPS reverse proxy and configure n8n’s public webhook URL for internet access.

    name: "n8n"
    services:
      n8n:
        image: "docker.n8n.io/n8nio/n8n:1.88.0"
        ports:
          - "127.0.0.1:5678:5678"
        environment:
          GENERIC_TIMEZONE: "UTC"
          N8N_ENCRYPTION_KEY: "${N8N_ENCRYPTION_KEY}"
        volumes:
          - "n8n_data:/home/node/.n8n"
        restart: "unless-stopped"
        networks:
          - "app-net"
    volumes:
      n8n_data: {}
    networks:
      app-net: {}
    

    Node.js + Postgres

    Put server.js and its runtime dependencies in ./app. Have the app listen on 0.0.0.0:3000 and use the supplied PG* variables.

    name: "node-postgres"
    services:
      app:
        image: "node:22.15.0-alpine"
        ports:
          - "3000:3000"
        environment:
          PGHOST: "postgres"
          PGPORT: "5432"
          PGUSER: "app"
          PGPASSWORD: "${POSTGRES_PASSWORD}"
          PGDATABASE: "app"
        volumes:
          - "./app:/app:ro"
        working_dir: "/app"
        command:
          - "node"
          - "server.js"
        depends_on:
          postgres:
            condition: "service_healthy"
        restart: "unless-stopped"
        networks:
          - "app-net"
      postgres:
        image: "postgres:17-alpine"
        environment:
          POSTGRES_USER: "app"
          POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
          POSTGRES_DB: "app"
        volumes:
          - "pg_data:/var/lib/postgresql/data"
        healthcheck:
          test:
            - "CMD-SHELL"
            - "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""
          interval: "10s"
          timeout: "5s"
          retries: 5
        restart: "unless-stopped"
        networks:
          - "app-net"
    volumes:
      pg_data: {}
    networks:
      app-net: {}
    

    WordPress + MySQL

    Set MYSQL_PASSWORD and MYSQL_ROOT_PASSWORD. MySQL stays on the shared network. Open WordPress on port 8080.

    name: "wordpress-mysql"
    services:
      wordpress:
        image: "wordpress:6.8.1-php8.3-apache"
        ports:
          - "8080:80"
        environment:
          WORDPRESS_DB_HOST: "mysql:3306"
          WORDPRESS_DB_USER: "wordpress"
          WORDPRESS_DB_PASSWORD: "${MYSQL_PASSWORD}"
          WORDPRESS_DB_NAME: "wordpress"
        volumes:
          - "wordpress_data:/var/www/html"
        depends_on:
          mysql:
            condition: "service_started"
        restart: "unless-stopped"
        networks:
          - "app-net"
      mysql:
        image: "mysql:8.4"
        environment:
          MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
          MYSQL_DATABASE: "wordpress"
          MYSQL_USER: "wordpress"
          MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
        volumes:
          - "mysql_data:/var/lib/mysql"
        restart: "unless-stopped"
        networks:
          - "app-net"
    volumes:
      wordpress_data: {}
      mysql_data: {}
    networks:
      app-net: {}
    

    Cloud hosts for Compose stacks

    Hetzner Cloud →

    Linux cloud servers for running a Compose stack on a dedicated VM.

    Audit Rules

    Image tag
    Choose an explicit version tag or digest. A missing tag and :latest can resolve to a different image on the next pull.
    Environment secrets
    Use ${VAR} for passwords, tokens, and keys. The audit flags literal values on common secret variable names.
    Restart policy
    Set restart: unless-stopped for long-running services that should come back after a host reboot. One-off jobs can use restart: "no".
    Published database port
    A mapping such as 5432:5432 publishes on all host interfaces. Bind to 127.0.0.1 for host-only access or omit the mapping for internal access.

    FAQ

    How do I convert docker run to Docker Compose?

    Paste the command into the docker run → Compose tab, then copy or download compose.yaml. In its directory, run docker compose config to validate it and docker compose up -d to start it.

    Does compose.yaml need a version field?

    No. Docker Compose uses the current Compose Specification. Start with services and declare named volumes and networks at the top level when you use them.

    How do I pass secrets to Docker Compose?

    Use ${VAR} in compose.yaml and supply the value from your shell or a local .env file. Keep .env out of version control. Commit .env.example with empty values to document what is required.

    How do I keep a database port private?

    For host-only access, bind it to loopback, for example 127.0.0.1:5432:5432. For access only from other Compose services, omit ports and connect by service name.

    How does Docker Compose request all GPUs?

    Use gpus: all with Docker Compose 2.30.0 or newer and a GPU-capable Docker host. The converter generates it from docker run --gpus all.