Skip to main content

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).
FeatureDocker CLIDocker Compose
ScopeSingle containerApp stack (many containers)
ConfigCLI flagscompose.yaml / docker-compose.yml
Networkmanualautomatic default network
Volumesmanualdeclared once, reused
Reproducibilitylowhigh (“config as code”)
Scalingmanual scriptingdocker 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 stop stops containers (keeps networks/volumes).
  • docker compose down removes containers + default network. Add -v to 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

  • entrypoint replaces the image entrypoint.
  • command replaces/extends the default CMD. Use command for simple overrides; only touch entrypoint when 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.

Deploy a Docker Compose Stack