Keenrig

What is Docker Compose? And when to skip it

Docker Compose describes a multi-container app in one YAML file. How compose.yaml works, the key commands, where it falls short, and when a catalog is easier.

Docker Compose is a tool for describing an application made of several containers in one file and starting them together with one command. Almost every self-hosted project ships a compose file in its README, so it is the format most people meet first. Here is what it does, what it does not do, and when you may not need to write one at all.

The problem it solves

Running one container with docker run is fine. Running an app plus its database plus a cache with the right networks, volumes, environment variables and start order quickly becomes a page of shell commands nobody wants to retype. Compose turns that page into a declarative file: you say what should exist, and docker compose up makes it so.

A minimal compose.yaml

services:
  app:
    image: ghcr.io/example/app:1.4.2
    ports:
      - "8080:8080"
    environment:
      DATABASE_URL: postgres://app:secret@db:5432/app
    depends_on:
      - db
    restart: unless-stopped

  db:
    image: postgres:16
    environment:
      POSTGRES_USER: app
      POSTGRES_PASSWORD: secret
    volumes:
      - db-data:/var/lib/postgresql/data
    restart: unless-stopped

volumes:
  db-data:

A few things to notice. Services find each other by name (the app reaches the database at db:5432) because Compose puts them on a shared network. The named volume db-data keeps the database files when the container is replaced. And the old top-level version: field you see in older guides is obsolete in Compose v2 — you can leave it out.

The commands you actually use

docker compose up -d        # create and start everything in the background
docker compose ps           # what is running
docker compose logs -f app  # follow one service’s logs
docker compose pull         # fetch newer images for the tags in the file
docker compose up -d        # recreate containers whose image or config changed
docker compose down         # stop and remove containers (volumes stay)

Note the space: docker compose (v2, a Docker CLI plugin) replaced the separate docker-compose binary. Most current docs use the plugin form.

Variables, .env files and overrides

Two features make compose files easier to share and reuse. First, variable interpolation: Compose reads a file called .env next to compose.yaml and substitutes values into the file, so the same compose.yaml works on several machines with different secrets.

# .env (not committed to git)
POSTGRES_PASSWORD=change-me
APP_VERSION=1.4.2

# compose.yaml
image: ghcr.io/example/app:${APP_VERSION}
environment:
  POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}

Second, override files: if compose.override.yaml exists, Compose merges it on top of compose.yaml automatically. Projects use this to keep the shared file clean and put machine-specific changes — an extra port, a different volume path — in the override. Run docker compose config to see the final merged result before you start anything; it is the quickest way to catch a variable that did not resolve.

Where Compose stops

Compose is excellent at “start these containers this way on this machine”. It deliberately does not cover the rest of running an app for months:

  • HTTPS and domains: you add a reverse proxy yourself, as another service or on the host.
  • Backups: volumes are just directories; nothing copies them anywhere.
  • Updates: docker compose pull follows whatever the tag points to today. If the file says latest, two pulls a month apart can give you different software.
  • Recovery from drift: if someone edits a container by hand or the file on disk changes, nothing notices until the next up.
  • More than one server: Compose is single-host. Swarm (docker stack deploy) reads a similar format across nodes; Kubernetes needs different manifests.
  • Safety of copied files: a compose file can ask for privileged mode, the host network, or a bind mount of /. Pasting one from the internet trusts its author with your server.

Good habits if you use Compose

  • Pin image versions, ideally by digest (image: postgres:16@sha256:…), so a reinstall gives the same build.
  • Keep secrets in an .env file next to compose.yaml, out of git, with tight permissions.
  • Only publish the ports you need; put apps behind one reverse proxy rather than exposing each on its own port.
  • Write down where each volume lives and back those paths up.
  • Read any compose file you copy before running it, especially privileged, network_mode and volumes lines.

Updating a compose app safely

A safe update is a short routine: read the release notes for breaking changes, take a backup of the volumes, change the pinned version in the file, then run docker compose pull and docker compose up -d. Check the logs and the app itself before deleting the old image. If something is wrong, put the old version back in the file and run up -d again — which only works if the backup was taken before any database migration ran.

When a one-click catalog is easier

If the app you want is a well-known open-source tool, you may not need to write or maintain any compose file. That is the idea behind Keenrig’s catalog: each entry is a signed manifest that pins an exact image digest, declares its volumes and health check, and sets the environment the app needs to work behind a proxy. You press Install; Keenrig creates the container, routes the domain through its gateway with HTTPS, keeps the app’s data in a directory that its backup command captures, and restarts the app if it stops. It is the same model as Cloudron, but open source and free for unlimited apps on one server — see Keenrig vs Cloudron.

curl -fsSL https://get.keenrig.com | sudo sh

For example, the n8n entry runs one container with its data volume, sets WEBHOOK_URL to the app’s domain and tells n8n there is one proxy in front of it — the details people usually get wrong in a hand-written compose file.

Limits of the catalog approach

  • You get the apps in the catalog. If yours is not there, Compose (or a platform such as Coolify or Dokploy that runs compose files — compared in Coolify vs Dokploy vs Keenrig) is the right tool.
  • Catalog entries choose a sensible single-server setup. n8n, for instance, runs without queue mode; if you need a tuned multi-service layout, write your own compose file.
  • Keenrig does not import arbitrary compose files from the admin panel today.