Docker lets you run apps in neat, separate packages called containers, and Docker Compose lets you describe those containers in a single text file. Instead of typing a long command every time, you write the setup once and start it with one short command. For a homelab, it is the easiest way to run services like Uptime Kuma, Pi-hole, or Jellyfin without making a mess of your system.
This Docker Compose tutorial for beginners takes you from a fresh Linux install to a running app, step by step. You don’t need to know Docker already. If you haven’t set up a machine yet, read our mini PC homelab guide for beginners first, and our Proxmox vs Ubuntu Server comparison if you’re still choosing an operating system.
What are Docker and Docker Compose?
Docker runs applications inside containers. A container holds an app and everything it needs, so it behaves the same on any machine, and it stays separate from the rest of your system. You can delete a container without leaving files scattered across your server.
Docker Compose is a tool that comes with Docker. You describe your containers in a file written in YAML, a simple format based on indentation, and Compose creates and manages them for you. One file can describe a single app or a whole stack of connected services.
Why use Compose instead of plain Docker commands?
You can start a container with a single docker run command, but those commands get long fast, with ports, folders, and settings all squeezed into one line. Compose has clear advantages for a homelab:
- Repeatable. The file is a record of exactly how the app is set up.
- Easy to change. You edit one line and apply it, rather than rewriting a command from memory.
- Easy to back up. The file is small and sits in a folder you can copy.
- Easy to move. Copy the folder to a new machine and start it there.
What you need before you start
- A Linux machine, such as a mini PC running Ubuntu Server, or a Linux virtual machine
- Access to it over SSH or at the keyboard
- An internet connection
- A user account with sudo rights
Step 1: Install Docker
The safest way to install Docker is to follow the official instructions for your operating system, because the steps and package names change over time. Use the official Docker Engine installation guide and choose your distribution. The installation includes the Compose plugin, which is what gives you the docker compose command.
When it finishes, check that both parts work:
docker --version
docker compose versionIf both print a version number, you’re ready. Note that the modern command is docker compose with a space. Older guides use docker-compose with a hyphen, which was an earlier, separate tool.
Step 2: Create a tidy folder structure
Give each app its own folder under one parent folder. This keeps things organized and makes backups simple, because one parent folder covers everything. We use /srv/docker in this guide:
sudo mkdir -p /srv/docker/uptime-kuma
sudo chown -R $USER:$USER /srv/docker
cd /srv/docker/uptime-kumaThe second command gives your user ownership of the folder, so you can edit files without typing sudo each time.
Step 3: Write your first Compose file
We’ll run Uptime Kuma, a free tool that watches your other services and alerts you when one goes down. Create a file named compose.yaml in the folder:
nano compose.yamlPaste in this content:
services:
uptime-kuma:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
restart: unless-stopped
ports:
- "3001:3001"
volumes:
- ./data:/app/dataYAML cares about spaces, so use spaces, not tabs, and keep the indentation exactly as shown. Save the file in nano with Ctrl+O, then exit with Ctrl+X.
What each line means
- services: the list of containers in this file.
- uptime-kuma: a name you choose for this service.
- image: the package Docker downloads. The part after the colon is the version tag. Check the project’s page for the tag it currently recommends.
- container_name: a friendly name so commands are easier to read.
- restart: unless-stopped: brings the app back after a reboot or crash, unless you stopped it yourself.
- ports: maps a port on your machine to a port in the container, written as host:container. Here, port 3001 on your server opens the app.
- volumes: links a folder on your server to a folder in the container. This is where the app keeps its data, so it survives if the container is removed.
Older tutorials start the file with a version: line. Current versions of Compose no longer need it, so you can leave it out.
Step 4: Start the app
From the same folder, run:
docker compose up -dDocker downloads the image the first time, then starts the container. The -d option means “detached,” so it runs in the background and gives you your terminal back. Open a browser on another computer on your network and go to http://YOUR-SERVER-IP:3001, replacing the address with your server’s IP. If you don’t know it or want it to stay the same, see our guide to home network basics for homelab beginners.
You should see the Uptime Kuma setup page, where you create an admin account.
Everyday Docker Compose commands
Run these from the folder that holds your compose.yaml:
| Command | What it does |
|---|---|
docker compose up -d | Creates and starts the containers in the background |
docker compose ps | Shows which containers are running |
docker compose logs -f | Shows live logs, useful for troubleshooting (Ctrl+C to stop watching) |
docker compose restart | Restarts the containers |
docker compose pull | Downloads newer versions of the images |
docker compose down | Stops and removes the containers |
Running docker compose down does not delete your data when you use a folder like ./data, because that folder lives on your server. Adding the -v option removes named volumes, so avoid it unless you mean to wipe that data.
How to update an app
To move to a newer version, pull the new image and recreate the container:
docker compose pull
docker compose up -dCompose only restarts what changed. Before big updates, make a backup of the app’s folder, as described in our homelab backup strategy for beginners.
Keeping settings out of the file
As your files grow, you’ll want to keep passwords and settings separate. Compose can read values from a file named .env in the same folder. In your Compose file you write a placeholder such as ${DB_PASSWORD}, and Compose fills it in from the .env file. Keep that file private and never publish it online.
Common beginner problems
- “Permission denied” when running docker. Your user may not have access to Docker. Running commands with sudo works, but be careful: giving a user Docker access is similar to giving them administrator rights, so only do it for accounts you trust.
- YAML errors. Almost always a spacing mistake. Run
docker compose configto check the file for problems. - “Port is already allocated.” Something else is using that port. Change the left-hand number, for example
"3002:3001". - The page won’t load. Check
docker compose psanddocker compose logs, and confirm you’re using the right IP address and port. - Data disappeared. You may have skipped the
volumessection, so the data lived inside the container only. Always map a folder for anything you want to keep.
Safety tips for a homelab
- Keep services on your home network until you understand firewalls and secure remote access.
- Use images from official or well-known publishers and read their documentation.
- Update regularly, since old images can contain known security problems.
- Don’t share the Docker control socket with a container unless a trusted project’s instructions require it.
Frequently asked questions
Is Docker Compose free?
Yes. Docker Engine and the Compose plugin are free and open source for use on a home server.
Should the file be called compose.yaml or docker-compose.yml?
Both work. The current documentation recommends compose.yaml, and older guides use docker-compose.yml. Pick one and use it for all your apps.
Can I run several apps in one Compose file?
Yes. Add more entries under services:. For unrelated apps, though, separate folders keep things easier to manage and back up.
Do I need Docker if I use Proxmox?
Not necessarily, but it’s a very popular way to run apps. The usual approach is to run Docker inside a small Linux virtual machine on Proxmox.
Final thoughts
Docker Compose turns a messy pile of commands into a single readable file. Install Docker, make one folder per app, write a short compose.yaml, and start it with docker compose up -d. Once Uptime Kuma works, adding Pi-hole, Jellyfin, or another app follows the same pattern. Back up your folders as you go, and your homelab will stay easy to rebuild.