Docker vs Docker Compose
A common question is: what’s the difference between Docker and Docker Compose? If you’re deploying one container, the Docker CLI is enough. If you’re running an app stack (web + DB + cache), Docker Compose is usually the right tool.
Docker Compose vs Docker (the real difference)
- Docker = build and run individual containers (
docker build,docker run,docker stop). - Docker Compose = define and run multi-container applications in one YAML (
docker compose up).
| Feature | Docker CLI | Docker Compose |
|---|---|---|
| Scope | Single container | App stack (many containers) |
| Config | CLI flags | compose.yaml / docker-compose.yml |
| Network | manual | automatic default network |
| Volumes | manual | declared once, reused |
| Reproducibility | low | high (“config as code”) |
| Scaling | manual scripting | docker compose up --scale |
What is Docker Compose?
Docker Compose is a tool that reads a YAML file and starts the services (containers), networks, and volumes your app needs—consistently, on any machine.
Minimal example (web + Postgres):
services:
web:
image: my-web-app
ports: ["8080:8080"]
depends_on: [db]
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: secret
Run it:
docker compose up -d
“docker compose is not a docker command”
This usually happens when:
- you’re using an older Docker install where Compose v2 isn’t available, or
- you still have Compose v1 (
docker-compose) but not v2.
Quick checks:
docker compose version
docker-compose version
On Linux, the simplest fix is installing/upgrading Docker and Compose (v2) via your distro packages or Docker’s official repo.
Dockerfile vs Docker Compose
- Dockerfile = how to build an image.
- Compose file = how to run images (ports, env, volumes, networks).
Docker Compose vs docker build
You still use docker build (or Compose build:) to create images. Compose then runs them.
Common Compose questions (quick answers)
docker compose down vs stop
docker compose stopstops containers (keeps networks/volumes).docker compose downremoves containers + default network. Add-vto remove volumes too.
docker compose remove container
Use:
docker compose rm -f
Or docker compose down to remove the whole stack.
docker compose scale
docker compose up -d --scale web=3
Works well for stateless services behind a load balancer.
docker compose privileged
privileged: true gives a container broad host access. Avoid unless you truly need it (e.g., low-level device access). Prefer specific capabilities (cap_add) and read-only mounts.
docker compose devices / device
For passing hardware through:
services:
app:
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
docker compose platform / docker compose platform amd64
Useful for cross-arch images (e.g., running amd64 images on arm64):
services:
app:
image: some/image:tag
platform: linux/amd64
docker compose entrypoint vs command
entrypointreplaces the image entrypoint.commandreplaces/extends the default CMD. Usecommandfor simple overrides; only touchentrypointwhen you must control the startup binary.
docker compose container alias
Compose supports network aliases:
services:
api:
networks:
default:
aliases: ["backend"]
Kubernetes vs Docker Compose
- Compose is great for local dev, small servers, and simple production stacks.
- Kubernetes is better for larger systems: scheduling across nodes, advanced rollout strategies, autoscaling, policies.
A common path: Compose → prove it works → Kubernetes when you outgrow it.
Portainer Docker Compose
Portainer can deploy Compose stacks via its UI, but the underlying concept is the same: a Compose file that defines services and how they connect.
Docker Compose alternatives
If you’re looking for a Docker Compose alternative:
- Kubernetes (bigger systems)
- Nomad (simpler cluster scheduling)
- Podman Compose / Quadlet (Podman-based workflows)
Hostim supports Docker and Docker Compose
Hostim.dev can deploy a single Docker image or a full Docker Compose stack (apps + databases + volumes) without manual infrastructure work.