Introduction: Why Docker Compose Exists
Let’s face it: you love running 17 terminal windows - that’s old practise( headless), but nowadays with Docker Desktop ( GUI) you’d probably still end up running 17 containers - just to start your app’s microservices.
Who doesn’t enjoy frantically typing docker run -p this -v that , env something
while praying to the DevOps gods? Enter Docker Compose, the tool that does what you definitely have time to do manually. It’s like a babysitter for your containers, except it doesn’t judge you for needing a babysitter.
Microservices: When Your App Needs a Divorce Lawyer
Microservices architecture is the art of splitting a monolithic application into smaller, independent services that communicate via passive-aggressive API calls. Each service handles one job (e.g., authentication, payments, cat GIF generation) and lives in its own containerized bubble, because collaboration is overrated. Or you could think that because all those little components are glued together, therefore the app works!
Real-World Example: Check out Umami’s GitHub repo, a self-hosted analytics tool. Their docker-compose.yml
defines:
- A PostgreSQL service (because data deserves its own drama).
- A Redis service (for caching trust issues).
- The Umami app itself (judging your website traffic).
Each service runs in isolation, scales independently, and gossips over a shared network. If the database crashes, the app keeps running, ignoring it like a group chat after someone says “OK.” Docker Compose stitches them together, proving even divorced services can coexist for the sake of the children (your users).
TL;DR: Microservices = “I don’t need you, but Docker Compose says I do.” 🐳💔
Step 1: Install Docker Compose (Because You Haven’t Suffered Enough)
First, install Docker and Docker Compose. Lucky for you, and lucky for me too, since we are using Docker Desktop ( refer to part 1), Docker Compose is already included, so we can skip this step.
If you’re on Linux, assuming you have Docker Engine and Docker CLI installed, and want to install Docker Compose as a plugin, read their docs or follow this short guide:
Installing Docker Compose On Linux Server
Step 1: Choose Your Pain
Ah, installing Docker Compose, the fun part where you get to pick between two equally thrilling options:
- Using Docker’s Repository (for optimists who trust third-party sources).
- Manual Installation (for masochists who enjoy doing things the hard way).
Note: This guide assumes you’ve already installed Docker Engine and Docker CLI, because apparently, you enjoy assembling IKEA furniture without instructions.
Method A: Repository Installation (For the Gullible)
Add Docker’s Repository
Follow their delightfully vague distribution-specific instructions for your OS. What could go wrong?Update & Install
Copy-paste these commands and pray:Ubuntu/Debian (RIP sanity):
sudo apt-get update # Watch the progress bar like it’s Netflix sudo apt-get install docker-compose-plugin # Accept your fate
RPM-Based Distros (Fedora/CentOS):
sudo yum update # Because 45 minutes of updates is *fine* sudo yum install docker-compose-plugin # Embrace dependency hell
Verify It Worked (Spoiler: It Won’t)
Run:docker compose version # Cross your fingers
Expected output:
Docker Compose version vN.N.N
(whereN.N.N
= version you’ll never remember).
Method B: Manual Installation (For Gluttons for Punishment)
Note: This is where you’ll learn to love repetitive tasks.
Download the Binary (Because Automation is Overrated)
Run this totally intuitive command:DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} mkdir -p $DOCKER_CONFIG/cli-plugins curl -SL https://github.com/docker/compose/releases/download/v2.35.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
Translation: “Hey GitHub, give me that sweet, untrusted binary!”
Make It Executable (Or Don’t, Live Dangerously)
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose # Grant permission to ruin your day
Pro Tip: If you want every user to suffer, use:
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-compose # Spread the pain
Verify (For the Delusional)
docker compose version # Output: A version number you’ll immediately forget
Updating: Because You’ll Definitely Remember to Do This
Repeat the installation steps every time there’s an update. Docker’s motto: “Why fix it when you can make them reinstall it?”
Conclusion: Was It Worth It?
Congratulations! You’ve installed Docker Compose. Now you’re ready to write YAML files that’ll fail in exciting new ways. Remember: If it breaks, it’s your fault. Always.
P.S. Save this guide, you’ll need it again in 3 months when the next breaking change drops. 🐳💥
Step 2: The docker-compose.yml
File: YAML Hell, But Make It Fashion
Create a docker-compose.yml
file. YAML: where indentation matters more than your therapist’s advice. Here’s a starter template for a basic app (because you’re definitely starting with “basic”):
version: '3.8' # Use 3.8 because 4.0 is for people who enjoy disappointment
services:
web:
image: your-app:latest # Latest tag: because debugging is fun!
ports:
- "80:80" # Map port 80 to port 80. Groundbreaking.
environment:
- DEBUG=True # You’ll need this when everything explodes
depends_on:
- db # Because the database should *totally* be ready in 0.2 seconds
db:
image: postgres:13 # The version you’ll forget to update
volumes:
- pg_data:/var/lib/postgresql/data # Persist data? How novel.
environment:
- POSTGRES_PASSWORD=password # Security is someone else’s problem
volumes:
pg_data: # Magic storage that disappears if you sneeze
Aight, you don’t have to actually create this docker-compose file, this is just to show you that how this not-so-simple
yaml
file can save you from runningdocker run image-name
command multiple times, as well as to close/stop multiple containers.
Since we won’t create some docker-compose files ourselves, we’ll gonna use other’s. Therefore I’ll introduce you an useful tool like I did in previous guide, but this time, we’ll run a docker-compose
file instead of an image.
Ever have you wanted to summary - or something like that - your documents, like PDF, using AI but were concerned about privacy or confidentiality?
Well, say hello to RAGFlow, it’ll help you get the job done, even with Local AI Models like Ollama
.
Retrieval-Augmented Generation
) engine based on deep document understanding. It offers a streamlined RAG workflow for businesses of any scale, combining LLM (Large Language Models) to provide truthful question-answering capabilities, backed by well-founded citations from various complex formatted data.git clone https://github.com/infiniflow/ragflow.git
This command will clone(download ) this repo to your computer, the default destination will be C:/User/Your-Username/ragflow
cd ragflow/docker
Run this after finish cloning to navigate to C:/User/Your-Username/ragflow/docker
in which the docker-compose file is located.
Step 3: Run It (And Pray)
Inside that directory, execute the command below, this command will name your compose stack “ragflow”, while the default command( from instruction on Github) will let it be “docker” ( default), and might conflict with your future stacks, who knows?
docker compose -f docker-compose.yml -p ragflow up -d
Example
If your app crashes immediately, welcome to Docker! Common fixes include:
- Blaming the release (
:latest
doesn’t mean it’s stable.) - Realizing you that forgot some steps.
- Follow logs to see if there’re any bugs, because you’re a masochist.
docker-compose logs -f
- Browsing the
#Issue
section on Github repo to see if you’re lucky to catch someone that faced the problem the same as yours.
After waiting for it to pull the images and build container, you might encounter an error like me: dependency failed to start: container ragflow-mysql is unhealthy
Try this fix
$ chmod 644. /init.sql
And then run this again
docker compose -f docker-compose.yml -p ragflow up -d
And now you’ll see the compose stack is created and running on Docker
You can now finally access it via localhost:80
on your browser
Step 4: Debugging: The Five Stages of Grief
Denial: “It worked on my machine!”
Anger: “Why is MySQL using 200% CPU?!”
Bargaining: “I’ll never use
:latest
again. Please work.”Depression:
docker-compose down -v
(nuclear option). The right command for Ragflow is actuallydocker compose -f docker-compose.yml -p ragflow down -v
, remember this if you want to force stop.Acceptance: Add
restart: always
and call it a day.
Step 5: Advanced Features You’ll Ignore
Docker Compose has tons of features you’ll never use, like:
- Networks: Because default networks are for amateurs.
- Secrets: Store passwords in plaintext like a rebel.
- Profiles: Organize services? Sure, Jan.
Conclusion: Embrace the Chaos
Docker Compose is the duct tape of container orchestration, it’s janky, fragile, and somehow holds your entire career together. Is it perfect? No. Is it better than manually managing containers? Obviously. Now go forth and docker-compose down
your problems away.
P.S. If this tutorial didn’t work, it’s your fault. Docker Compose is flawless. Probably.
Final Tip: When in doubt, add more RAM. 🐳💥