Docker-Grundlagen für Self-Hosting
Lerne Images, Container, Volumes und Docker Compose, um selbst gehostete Apps souverän bereitzustellen.
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 examplejellyfin/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 versionAvoid 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/piholeWhat each part does:
-druns it in the background.--namegives the container a readable name.-p host:containerpublishes a port, making the app reachable at the host's IP.-v host_path:container_pathstores data on the host so it persists.--restart unless-stoppedstarts 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-stoppedSave 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
| Task | Command |
|---|---|
| List running containers | docker ps |
| See logs | docker logs -f <name> |
| Open a shell inside | docker exec -it <name> sh |
| See disk use | docker system df |
| Remove unused images | docker image prune |
| Update an app | docker 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:
- Back up the volumes and Compose files first.
- Read the project's release notes for breaking changes.
- Run
docker compose pullanddocker compose up -d. - Check the logs and confirm the app works.
- If it fails, set the previous version tag in the Compose file and run
up -dagain.
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
- Persist data in volumes or bind mounts, never only inside the container.
- Pin image versions for predictable updates.
- Back up your Compose files and data folders — they are your entire setup. See the backup strategy.
- Don't expose the Docker socket to containers you don't fully trust, and don't run containers as root unless needed.
- Keep secrets out of Compose files that you share or commit; use
.envfiles with restricted permissions. - 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
localhostbetween containers; it points to the container itself. Use the service name.
Where to go next
- Follow our tutorial to install Docker on Ubuntu.
- Deploy a first app such as Pi-hole or Jellyfin.
- Manage containers with a UI using Portainer.
- Compare Docker vs Podman.
- Browse self-hosted apps to deploy.
Master Compose and a whole world of self-hosting opens up.
Verwandte Artikel
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.
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.
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.