This Docker Compose for beginners guide shows you how to read your first compose.yaml file, the five commands you need, and how two containers work together. If Docker itself is new to you, read Docker in plain words first.

01What is Docker Compose?
Without Compose, you start a container by typing one long command with every setting in it. With Compose, you write those settings once in a text file, like a recipe card.
Compose comes with Docker Desktop on Windows and Mac. On Linux it is part of a normal Docker install. The file is usually called compose.yaml.
02How to read a Compose file
Here is a whole Compose file for Uptime Kuma, a popular app that checks your websites are up:
services:
uptime-kuma:
image: louislam/uptime-kuma:2
ports:
- "3001:3001"
volumes:
- ./data:/app/data
restart: unless-stopped Tap each word to see what it means:
services is the list of containers in this app. This file has one, named uptime-kuma. You choose the name.
image is the packed app to download and run. The part after the colon is the version.
ports opens a door to the app. The left number is the door on your computer and the right one is the door inside the container. Here you would open http://localhost:3001.
volumes is where the app keeps its data. The left side is a folder on your computer and the right side is the folder inside the container. Your data stays even if the container is deleted.
restart tells Docker what to do if the app stops. unless-stopped means "start it again, unless I stopped it myself".
Keep passwords and API keys out of your compose.yaml. Put them in a .env file next to it, and don't share that file.
03The five Docker Compose commands you need
Open a terminal in the folder that holds your compose.yaml, then:
| Command | What it does |
|---|---|
docker compose up -d | Starts the app and leaves it running in the background. |
docker compose ps | Shows what is running. |
docker compose logs -f | Shows what the app is saying. Press Ctrl + C to stop watching. |
docker compose pull | Downloads newer versions. Start the app again afterwards to use them. |
docker compose down | Stops the app and removes its containers. Your data folders stay. |
04A Compose file with two containers
Compose really helps when an app has more than one part. This file runs Ollama, which runs AI models, and Open WebUI, a chat page for them:
services:
ollama:
image: ollama/ollama
volumes:
- ./ollama:/root/.ollama
restart: unless-stopped
open-webui:
image: ghcr.io/open-webui/open-webui:main
ports:
- "3000:8080"
environment:
- OLLAMA_BASE_URL=http://ollama:11434
volumes:
- ./open-webui:/app/backend/data
depends_on:
- ollama
restart: unless-stopped Inside one Compose file, containers can find each other by their service name. That is why Open WebUI is told to look for Ollama at http://ollama:11434.
Start it with docker compose up -d, then open http://localhost:3000. Set up like this, the models run on the processor. Using a graphics card from inside Docker needs a little extra setup. New to Ollama? Read Ollama for beginners.
05Common Docker Compose mistakes
- Spacing. The indents matter. Use spaces, not tabs, and keep lines lined up as in the examples.
- Port already in use. Another app has that door. Change the left number, for example
"3002:3001". - Wrong folder. Run the commands in the folder that holds the file.
- Old commands. Older guides say
docker-composewith a dash. Usedocker composewith a space. - The version line. Older files start with
version:. You can leave it out.
Give each app its own folder holding its compose.yaml and its data folders. Back up that folder and you have backed up the app.
06What this means for CosmolinkOS
CosmolinkOS runs in Docker, for example as an app on TrueNAS. More platforms are planned. It needs at least a 2-core processor, 4 GB of memory (8 GB on TrueNAS) and 10 GB free on an SSD. See what you need.
07Questions people ask
What is the difference between Docker and Docker Compose?
Docker runs containers. Docker Compose is the part of Docker that starts one or more containers from a text file, so you don't have to type long commands.
Is it docker-compose or docker compose?
Use docker compose, with a space. The older docker-compose command, with a dash, is the legacy version.
Do I need the version line at the top of a Compose file?
No. Current Docker Compose ignores it, so new files can leave it out.
Where should I keep my compose.yaml file?
In a folder of its own for each app. Run the Compose commands from inside that folder.
Does docker compose down delete my data?
It removes the containers, not the folders your data is kept in. Adding the -v option also deletes the volumes named in the file, so leave it off unless you mean it.
Related guides: 12 home lab ideas to try.