Every self-hosting guide you read says “just run it in Docker” — and then you’re left wondering what Docker actually is. If that’s you, this guide is for you. By the end, you’ll understand containers well enough to run any self-hosted app with confidence.

This is the foundation that makes projects like Nextcloud, Vaultwarden, and Jellyfin possible.

What is Docker, in plain English?

Docker packages an app — plus everything it needs to run — into a self-contained unit called a container. Unlike a virtual machine (which emulates an entire computer), a container shares your server’s OS kernel but isolates the app’s files and processes.

The result: apps run the same way everywhere, install in seconds, and never conflict with each other.

Containers vs virtual machines

  • VMs: heavy, each runs a full OS, gigabytes of overhead.
  • Containers: light, share the kernel, start in milliseconds, use megabytes.

For a homelab, containers are almost always the better choice.

Why Docker is perfect for homelabs

  • Reproducible. A docker-compose.yml file describes your entire setup — rebuild anything in minutes.
  • Clean. Remove a container and its app is gone, no leftover files.
  • Portable. The same setup runs on a mini PC, a VPS, or a Raspberry Pi.

Install Docker and Docker Compose

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

Log out and back in, then verify:

docker --version
docker compose version

The four concepts you need to know

  1. Image — a read-only template for an app (like nginx or nextcloud).
  2. Container — a running instance of an image.
  3. Volume — persistent storage that survives container restarts and updates.
  4. Port mapping — expose a container’s port to your server (8080:80 means “server port 8080 → container port 80”).

Your first container

docker run -d --name my-nginx -p 8080:80 nginx

Open http://your-server-ip:8080 and you’ll see the default nginx page. Congratulations — you just ran your first container.

Docker Compose: describe your whole app in one file

For anything more than a single container, use a docker-compose.yml:

services:
  app:
    image: nginx
    ports:
      - "8080:80"
    volumes:
      - ./html:/usr/share/nginx/html
    restart: always

Then start it with:

docker compose up -d

The -d flag runs it in the background. This file is your app’s entire recipe — commit it to git and you can rebuild anywhere.

Commands you’ll use daily

docker ps                    # list running containers
docker logs <name>           # view logs
docker compose up -d         # start
docker compose down          # stop
docker compose pull          # update images
docker compose up -d         # apply updates

Common mistakes to avoid

  • Losing data — anything not in a volume disappears on restart. Always define volumes for data.
  • Exposing ports to the internet without thinking — use a reverse proxy or VPN.
  • Running outdated images — docker compose pull regularly for security fixes.

FAQ

Is Docker hard to learn?

The basics take about an hour. The concepts are simple; you’ll pick them up fast by actually running containers.

Do I need Docker for my homelab?

No, but it’s the easiest path. Bare-metal installs are harder to migrate and undo.

Can Docker run on a Raspberry Pi?

Yes — most popular apps publish ARM-compatible images.

Docker Compose vs docker run

You’ve now seen two ways to launch containers, and it’s worth knowing when to use each. docker run fires up a single container with a long list of flags — fast for quick experiments, but impossible to reproduce later. docker compose up reads a docker-compose.yml file that describes your entire app, so you can tear everything down and rebuild it identically on any machine.

For anything you plan to keep running, always use Compose. It’s self-documenting, handles multi-container apps, and turns updates into a single command.

Troubleshooting common errors

  • “port is already allocated” — another container is using that port. Either change your mapping or stop the conflicting container with docker stop <name>.
  • “permission denied” — your user isn’t in the docker group yet. Run sudo usermod -aG docker $USER, then log out and back in.
  • Container restarting in a loop — read the logs with docker logs <name>. Nine times out of ten it’s a typo in the config or a missing volume.

Keep your containers updated

Most self-hosting security problems come from running outdated images. This two-line habit fixes almost all of them:

docker compose pull
docker compose up -d

Run it weekly, or automate it with a cron job, and your homelab stays patched without you thinking about it.

Docker networking in one paragraph

By default, containers in the same compose file can reach each other by service name — that’s why Nextcloud can talk to its database at db:3306 with zero extra config. To expose a service to your server, you map a port (8080:80). To keep something private, simply don’t map a port. That one mental model covers 90% of homelab networking.

When NOT to use Docker

Docker is great, but not for everything. A few cases where bare metal makes more sense:

  • A single-purpose server (like a dedicated NAS) where one app uses the whole machine.
  • Low-RAM devices where container overhead actually matters.
  • Deep kernel integration — some networking or filesystem tools want direct access to the host.

For the vast majority of self-hosting, though, Docker is the right default.

The mental model to remember

Here’s the whole thing distilled into one sentence: images are templates, containers are running instances, volumes hold your data, and ports expose services. Describe your app in a docker-compose.yml, run docker compose up -d, and you’re done.

Keep that sentence in your head and every self-hosting guide on this site becomes a ten-minute job rather than a mystery. The hard part of homelabbing was never Docker — it was always just knowing what to run.

The bottom line

Docker is the glue that makes self-hosting approachable. Master these basics and every homelab guide on this site becomes a ten-minute job.