Instead of a giant docker-compose

Manage a shit-ton of smaller docker-compose files

The problem

I have multiple servers running in my home all doing their own thing for various people in our household. I’m not gonna lie, most of them run off a giant docker-compose file. But on some “play” servers I experiment more and get to try different organization strategies.

The “current” solution

This is gonna seem like a no-brainer, here goes:

One master yml, bunches of includes.

docker-compose.yml
include:
- path: 'actual/docker-compose.yml'
- path: 'codeserver/docker-compose.yml'
- path: 'glance/docker-compose.yml'
- path: 'homepage/docker-compose.yml'
- path: 'tududi/docker-compose.yml'
- path: 'vogon/docker-compose.yml'

And then my docker-apps directroy structure looks like this:

docker-apps directory structure
├── actual
│   ├── data
│   └── docker-compose.yml
├── codeserver
│   ├── config
│   └── docker-compose.yml
├── glance
│   ├── config
│   └── docker-compose.yml
├── homepage
│   ├── config
│   └── docker-compose.yml
├── tududi
│   ├── config
│   └── docker-compose.yml
├── vogon
│   ├── config
│   └── docker-compose.yml
├── .env
├── docker-compose.yml
└── recompose.sh

Example of a sub-service glance/docker-compose.yml file:

glance/docker-compose.yml
services:
glance:
container_name: glance
image: glanceapp/glance
restart: unless-stopped
volumes:
- ${APPDATADIR}/glance/config:/app/config
ports:
- 9000:8080

I use each directory to house any volumes, config data, etc. for that service. Until it graduates to family-critical I’m okay with wiping this out occasionally.

And they all share the same .env file:

.env
COMPOSE_HTTP_TIMEOUT='60'
APPDATADIR='/home/joe/docker-apps'
GID='******'
HOSTNAME='******'
PGID='******'
PUID='******'
TZ='******'

And when I want to add or remove a service, I just edit the master docker-compose.yml file and restart the services.

I also have a recompose.sh script that I can run to completely rebuild all the services.

recompose.sh
#!/bin/bash
docker compose stop
docker compose rm
docker compose pull
docker compose up -d

And I can run it with:

recompose.sh
./recompose.sh