CosmolinkOS Board now

Docker Compose for beginners

FOR BEGINNERS5 MIN READ
COSMO
COSMO'S SHORT ANSWER

Docker Compose lets you describe an app in one small text file, called compose.yaml, and start it with one command. The file lists the app's containers, ports and folders, so you can set it up the same way again any time.

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.

A tall glowing plan panel with coloured cables running to four shipping containers in a row.
One file describes every container.

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.

SENTRY'S TIP

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:

Everyday Docker Compose commands
CommandWhat it does
docker compose up -dStarts the app and leaves it running in the background.
docker compose psShows what is running.
docker compose logs -fShows what the app is saying. Press Ctrl + C to stop watching.
docker compose pullDownloads newer versions. Start the app again afterwards to use them.
docker compose downStops 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

  1. Spacing. The indents matter. Use spaces, not tabs, and keep lines lined up as in the examples.
  2. Port already in use. Another app has that door. Change the left number, for example "3002:3001".
  3. Wrong folder. Run the commands in the folder that holds the file.
  4. Old commands. Older guides say docker-compose with a dash. Use docker compose with a space.
  5. The version line. Older files start with version:. You can leave it out.
COSMO'S TIP

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

GOOD TO KNOW

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.

WAITLIST OPENBe first to hear when CosmolinkOS is ready to try.

▸Keep going