Docker Compose Made Simple: A HomeLab Beginner's Cheat Sheet
Introduction
As someone who transitioned from professional coding to self-hosting adventures, I've fallen in love with creating HomeLab setups and optimizing network gear.
When I discovered Docker and its companion tool Docker Compose, it transformed how I deploy personal projects.
From my first day using Docker, I started using docker-compose. Back then, it was a Python-based tool separate from the main Docker CLI.
I've always followed this principle: even if a deployment can be done with a single Docker command, using Docker Compose is better for self-hosted projects.
Although docker-compose wasn't perfect initially, its rewrite in Go language and integration into Docker CLI made me appreciate it even more.
Today, I use docker-compose commands far more often than basic Docker commands.
Why Beginners should choose Docker Compose over Docker run commands
🔹 No More Guesswork: Store all setup steps in a human-readable file
🔹 Time Travel Superpower: Recreate any project version effortlessly
🔹 Community Friendly: Share your work with clear instructions
🔹 Growing Together: Witness Docker's tooling evolution first-hand
And that is why I create this site: A Tool that can convert a docker run command to a docker-compose.yml, and share various docker-compose.yml-s that self-hosted beginners can tinker with.
My Essential Commands
Below is a cheatsheet for docker compose. I create this for myself, but I hope it can help anybody find here. I will update it from time to time.
1. Start Services in Background
docker compose up -d
-d
: Detached mode (run containers in the background).
2. Stop and Remove Containers/Networks
docker compose down
- Add
-v
to delete volumes:
docker compose down -v
3. Rebuild Images and Restart
docker compose up -d --build
--build
: Force rebuild of images before starting.
4. View Container Logs
docker compose logs
- Follow logs in real-time:
docker compose logs -f
5. List Running Containers
docker compose ps
- Show all containers (including stopped ones):
docker compose ps -a
6. Execute Commands in a Container
docker compose exec <service_name> <command>
- Example (access shell in a running container):
docker compose exec app sh
7. Validate Compose File
docker compose config
- Check syntax and merged configuration.
8. Pull Latest Images
docker compose pull
- Updates images defined in
image
fields of yourdocker-compose.yml
.
9. Scale Specific Services
docker compose up -d --scale <service_name>=<num_instances>
- Example (run 3 instances of
worker
service):
docker compose up -d --scale worker=3
10. Restart Services
docker compose restart
- Target specific services:
docker compose restart <service_name>
Notes:
- Replace
<service_name>
with your service's name fromdocker-compose.yml
. - Commands assume
docker-compose.yml
exists in the current directory. Use-f <file_path>
to specify a custom Compose file. - Commands are based on Docker Compose v2+.
- Always check the official docs for updates.