Blog · Part 1, Foundations
Docker and Compose for people who've never used them
Containers keep each app sealed in its own box, and one text file describes the whole stack. Install Docker, learn six commands, and you're ready.
Every app in this stack will run in a container. If you’ve never used containers, this is the only article you need before tomorrow’s install.
What a container is
A container is an app packaged with everything it needs to run: the right libraries, the right versions, the right settings. It runs sealed off from the rest of the system, and from other containers.
Why it’s worth it for a media server:
- No dependency mess. Jellyfin wants one version of a video library, Sonarr another. In containers, neither cares.
- Clean updates. Updating an app means swapping its container for a newer one. Your settings live outside, untouched.
- Easy to move. The whole stack is one text file and a few folders. Copy them to a new machine and run one command.
The app inside the container only sees what you hand it: a port to listen on, and the folders you choose to share (we call those volumes or mounts). That’s why Day 4’s folder layout matters so much.
What Compose is
Docker runs containers. Docker Compose lets you describe several containers in one file, compose.yaml, and start them all with one command. That file becomes the single source of truth for your whole server.
A minimal example:
services:
hello:
image: nginx:latest
ports:
- 8080:80
restart: unless-stopped
Reading it line by line:
services:lists the containers.hello:is a name you choose.image:is what to run, downloaded from a public registry.ports:maps a port on your server (left) to a port inside the container (right). Here, your server’s port 8080 reaches the container’s port 80.restart: unless-stoppedbrings it back after a reboot or a crash.
YAML is fussy about indentation: two spaces per level, never tabs.
Install Docker
On Debian or Ubuntu, Docker’s own convenience script installs Docker and the Compose plugin in one go:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
If you prefer to add Docker’s package repository by hand, the official install guide walks through it for each distribution. Either way, avoid the docker.io package from your distribution’s own repository; it’s often old.
Let your user run Docker without sudo:
sudo usermod -aG docker $USER
Log out and back in for that to take effect, then check:
docker run --rm hello-world
docker compose version
The first prints a welcome message. The second prints a version number (2.x or later). If both work, you’re set.
The six commands you’ll use
Run these from the folder that holds compose.yaml, which for us is /opt/media-server.
| Command | What it does |
|---|---|
docker compose up -d |
Start everything in the file (or apply changes you made to it). -d runs it in the background. |
docker compose ps |
List the containers and whether they’re running. |
docker compose logs -f jellyfin |
Follow one app’s log. Ctrl+C to stop following. |
docker compose restart sonarr |
Restart one app. |
docker compose pull |
Download newer versions of every image. |
docker compose down |
Stop and remove the containers. Your settings and media are untouched. |
That’s genuinely most of it. Change compose.yaml, run docker compose up -d, check the logs if something looks wrong.
How containers find each other
Every service in the same compose.yaml joins a private network where each one can reach the others by service name. Sonarr can reach Jellyfin at http://jellyfin:8096, and Seerr can reach Radarr at http://radarr:7878, without knowing any IP address.
You’ll use this in Part 3. When an app asks for another app’s address, give it the service name, not localhost. Inside a container, localhost means the container itself.
Environment variables
Many images are configured with environment variables:
environment:
- TZ=Europe/Paris
- PUID=1000
- PGID=1000
TZ sets the time zone, so schedules and logs show your local time. Find yours in the list of tz database names (for example America/New_York, Europe/London). PUID and PGID are the user IDs from yesterday.
Volumes
volumes:
- ./config/sonarr:/config
- /data:/data
Left of the colon is a path on your server; right is where it appears inside the container. ./config/sonarr is relative to the folder holding compose.yaml, so it means /opt/media-server/config/sonarr.
Everything the app writes to /config survives updates and restarts, because it actually lives on your disk.
Pin or follow?
Image names end with a tag, like :latest or :10.11. latest always moves to the newest release. A version number stays put until you change it.
For a home server, latest is reasonable for most apps as long as you have backups. Day 25 covers updating calmly, and when to pin.
Create the file
Create the empty file now, so tomorrow can fill it:
cd /opt/media-server
touch compose.yaml
Edit it with any text editor. nano compose.yaml is the friendliest in a terminal: Ctrl+O saves, Ctrl+X exits. If you’d rather edit from your laptop, VS Code’s Remote SSH extension opens files on the server as if they were local.
Tomorrow: the first real service. Jellyfin.
Use these tools with media you own or are authorized to use, and with public-domain works. Medusa does not host, provide, or stream any media of its own.