Skip to content
runonprem

Config generators

Docker Compose generator

Write a clean compose.yaml for a self-hosted app: image, ports, volumes, environment, restart policy and an external network for your reverse proxy — with YAML quoting that avoids the classic port and boolean pitfalls.

compose.yaml

services:
  web:
    image: nginx:1.27-alpine
    container_name: web
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    environment:
      TZ: "Etc/UTC"

Start it with docker compose up -d in the folder that holds the file.

How to use it

  1. Enter the image with a pinned version tag (e.g. nginx:1.27-alpine) rather than latest, so updates happen when you choose.
  2. List ports as host:container. Bind to 127.0.0.1 (127.0.0.1:8080:80) when only a reverse proxy on the same host should reach the app.
  3. List volumes as host-path:container-path; add :ro for read-only mounts.
  4. Copy or download the file and run docker compose up -d. Keep passwords in an .env file, not in a shared link.

Formula and method

services:
  <service>:
    image: <image:tag>
    restart: unless-stopped
    ports:
      - "host:container"        # always quoted
    volumes:
      - host-path:container-path(:ro)
    environment:
      KEY: "value"

Worked example

services:
  web:
    image: nginx:1.27-alpine
    container_name: web
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
    environment:
      TZ: "Etc/UTC"

FAQ

Do I still need "version:" at the top?

No. Docker Compose v2 follows the Compose Specification, which ignores the top-level version key and warns that it is obsolete.

Is it safe to put passwords in environment?

They end up in the file and in docker inspect output. Prefer an .env file next to compose.yaml (not committed to git) or Docker secrets, and never share a link containing them.

unless-stopped or always?

Both restart after crashes and reboots; unless-stopped keeps a container down after you stopped it on purpose, which is usually what you want in a homelab.

Related tools

Formulas reviewed November 27, 2026 by Novian · runs entirely in your browser · methodology