Zum Inhalt springen
ArtikelContainerAnfänger

Docker-Grundlagen für Self-Hosting

Lerne Images, Container, Volumes und Docker Compose, um selbst gehostete Apps souverän bereitzustellen.

von HomeServersGuide TeamAktualisiert 27. Oktober 20265 Min. Lesezeit

Docker is the fastest, cleanest way to run self-hosted apps. Instead of installing software directly on your server and fighting dependency conflicts, you run each application in an isolated container that includes everything it needs. Once these concepts click, you will be able to deploy almost anything you find on the internet.

Why containers suit a home server

  • Clean installs and removals. Deleting a container leaves no stray files or packages behind.
  • Reproducible. The same Compose file produces the same result on a new machine.
  • Isolated. One misbehaving app cannot easily break another.
  • Easy updates and rollbacks. Pull a new image, or go back to the previous version tag.
  • Huge ecosystem. Nearly every popular self-hosted project publishes an official image.

A container is not a virtual machine. It shares the host's kernel, so it starts in seconds and uses little memory. If you want full operating-system isolation, look at Proxmox. Many setups use both.

The four concepts you need

  • Image — a read-only template for an app (for example jellyfin/jellyfin). Images are downloaded from a registry such as Docker Hub or GitHub Container Registry and are identified by a name and a tag (for example jellyfin/jellyfin:10.10.3).
  • Container — a running instance of an image. You can start, stop and delete containers without touching the image.
  • Volume or bind mount — persistent storage that survives container updates. Without it, data written inside a container disappears when the container is recreated.
  • Network — how containers talk to each other and the outside world. Containers on the same user-defined network can reach each other by name.

Install Docker

On Ubuntu or Debian, install Docker Engine from Docker's official repository, which includes the docker compose plugin. Follow our install Docker on Ubuntu tutorial. Afterwards verify it works:

docker run --rm hello-world
docker compose version

Avoid adding yourself to the docker group on shared or exposed systems without understanding the risk: membership is effectively root access.

Your first container

docker run -d \
  --name pihole \
  -p 53:53/udp -p 8090:80 \
  -v /opt/pihole/etc:/etc/pihole \
  --restart unless-stopped \
  pihole/pihole

What each part does:

  • -d runs it in the background.
  • --name gives the container a readable name.
  • -p host:container publishes a port, making the app reachable at the host's IP.
  • -v host_path:container_path stores data on the host so it persists.
  • --restart unless-stopped starts it again after reboots or crashes.

Docker Compose: the real magic

Typing long docker run commands doesn't scale. Docker Compose lets you describe your whole stack in one file and manage it with a few commands:

services:
  jellyfin:
    image: jellyfin/jellyfin:latest
    container_name: jellyfin
    ports:
      - "8096:8096"
    volumes:
      - ./config:/config
      - /mnt/media:/media:ro
    restart: unless-stopped

Save it as compose.yaml in its own folder. Then:

docker compose up -d       # create and start
docker compose ps          # list services
docker compose logs -f     # follow the logs
docker compose down        # stop and remove containers (volumes stay)

Read the Docker Compose best practices for tips on environment files, health checks and structure.

Everyday commands

TaskCommand
List running containersdocker ps
See logsdocker logs -f <name>
Open a shell insidedocker exec -it <name> sh
See disk usedocker system df
Remove unused imagesdocker image prune
Update an appdocker compose pull && docker compose up -d

Networking in one minute

By default Compose creates a private network for each project. Containers in the same project reach each other by service name (http://db:5432), so you rarely need to publish internal ports like databases to the host. Only publish ports for services you actually want to reach from your network. If you want a deeper explanation, read Docker networking explained.

Updating safely

Updating is the part people forget:

  1. Back up the volumes and Compose files first.
  2. Read the project's release notes for breaking changes.
  3. Run docker compose pull and docker compose up -d.
  4. Check the logs and confirm the app works.
  5. If it fails, set the previous version tag in the Compose file and run up -d again.

Using latest is convenient but unpredictable; for important services pin a version and update on purpose. Tools such as Watchtower can automate updates, but automatic updates of everything can break things while you are away.

Golden rules

  1. Persist data in volumes or bind mounts, never only inside the container.
  2. Pin image versions for predictable updates.
  3. Back up your Compose files and data folders — they are your entire setup. See the backup strategy.
  4. Don't expose the Docker socket to containers you don't fully trust, and don't run containers as root unless needed.
  5. Keep secrets out of Compose files that you share or commit; use .env files with restricted permissions.
  6. Update regularly, and remove unused images and containers.

Common mistakes

  • Forgetting a volume, then losing data when the container is recreated.
  • Publishing database ports to the whole network.
  • Port conflicts, when two containers want the same host port.
  • Permission errors, because the container user cannot write to a bind-mounted folder. Match the user IDs.
  • Using localhost between containers; it points to the container itself. Use the service name.

Where to go next

Master Compose and a whole world of self-hosting opens up.

Verwandte Artikel

TutorialsContainerAnfänger

Docker unter Ubuntu installieren

Installiere Docker Engine und das Compose-Plugin aus dem offiziellen Docker-Repository auf Ubuntu Server, prüfe die Installation, starte deinen ersten Container und behebe typische Fehler.

4 Min. Lesezeit
AnleitungenContainerFortgeschritten

Docker Compose Best Practices for Home Servers

Structure Compose stacks, volumes, networks, secrets, healthchecks, logging and updates so your home server stays clean, secure and easy to rebuild.

5 Min. Lesezeit
AnleitungenContainerFortgeschritten

Docker Networking Explained for Home Servers

Bridge, host, macvlan and internal Docker networks explained: container DNS, publishing ports, reverse proxy patterns, firewall pitfalls and a troubleshooting checklist.

4 Min. Lesezeit