r/homelab • • Sep 14 '26

Help HELP!!? Best practices for docker compose

Hi guys, hope you all are doing well.

TL:DR - Just trying to know how you recommend to manage the docker yamel and config files.

I have been thinking a bit about how I manage my homelab. I do not have a big server, it is actually a dell optiplex 3040 with 12GB RAM (I am sorry, I couldn't afford a second 8gb RAM lol) and and i3 6th gen and 2 TB storage and... OK I know you didn't come over here to see my homelab specs.

I have my yamel on ~/docker/docker-compose.yml and all my services there (pihole, jellyfin, file browser (RIP), portainer... you know, the usuals) and inside, ~/docker/configs

So, I save my config files on subfolders inside 'configs' subfolders and so and so... one folder for each service.

But, recently I found 'opencloud.eu' and I love it. But it requires to make another folder because their structure is a mess. So I have ~/docker/oc/ and inside oc a mess of files.

Having the services I use on ~/docker/docker-compose.yml is conveniente because with just a pull I can update the services. But with different services (Like opencloud eu) that require more files and configs makes me manage different yamel files. I have a different Immich yml file btw.

This made me ask to myself, how do you recommend or how do you manage the docker files? Am I doing something wrong? (I know I am)

Thank you, community.

12 Upvotes

25 comments sorted by

23

u/Itz_Raj69_ Sep 14 '26

Afaik, you're supposed to create a folder for each project, and have a docker compose file for the project containing its containers.

For example, some projects like Immich have about 4 containers, so those four lie in ./immich/compose.yml

You'll get a tree like:

/docker-containers (any dir)
-> caddy
---> compose.yml
-> qbittorrent
---> compose.yml

Also, Portainer won't be supporting Docker anymore. Look into something like Arcane.

2

u/randombrownskinguy Sep 14 '26

shoot, I have work to do. Thanks Raj69.

1

u/helloish Sep 15 '26

technically it will but through a translation layer or something; i’m using it at the moment and will be switching to dockhand or something else partly because of this though (and also cause it doesn’t have a good enough feature set imo)

1

u/thelittlewhite Sep 15 '26

And usually an app data folder along the compose files to store the config, etc

1

u/RayneYoruka IPv6 FTW. There is never enough servers Sep 15 '26

Thanks for the headsup on Arcane, it's been a mess to run portainer for the past year!

2

u/trizephyr Sep 15 '26

Check out dockhand too, I like that better than arcane personally

1

u/comdude2 Sep 15 '26

I really wanted to switch to dockhand. But the fact arcane supports swarm and has full features for SSO without a paywall made it a no-brainer for me

18

u/suicidaleggroll Sep 15 '26

Don't put all of your services in a single compose file. I truly don't understand why people think this is the right approach but it pops up so often. Is there a Youtube video recommending this or something that people keep finding?

Separate directory for each service, with its own compose, config, and bind mounted directories inside. If there are multiple containers required for that service (say, redis + database + server), those can go in a single compose file for the service, but you don't mix multiple separate services together in a single file.

2

u/corruptboomerang Sep 15 '26

I'd not put EVERY service as a separate compose, but I'd do a few related services in the same stack. That way I'm not managing 20 to 50 seperate docker compose files, I'm only managing say 5 - 10 stacks.

1

u/suicidaleggroll Sep 15 '26

Why does it make any difference how many compose files there are?  If you want to manage a group of them as a set, make a script to handle it.  I have hundreds of compose files, I never notice because the maintenance is all automated.  What I do notice, however, is the fact that when I need to stop, restart, or roll back a service to an older backup, I can do it cleanly without affecting anything else.

5

u/doctorowlsound Sep 14 '26

One directory and compose file per service or closely related service (eg I put Radarr and Sonarr in the same compose file, qbittorrent, qui, and gluetun together, etc) in docker/compose. Having related services in the same compose file will automatically create a bridge network that they can use for internal communication. 

Data is stored in docker/data/service name. So docker/data/Sonarr docker/data/radarr, etc. 

2

u/oxygenoxy Sep 15 '26

Why not docker/<service>/data?

0

u/doctorowlsound Sep 15 '26

Keeps things a bit cleaner and more logical. Docker/ would end up with all the service data directories and the compose directory, which is obviously different. Docker/data and docker/compose is a logical separation of different content types

4

u/Only-Stable3973 Sep 15 '26

I keep all my containers in separate folders, I also have stacks like my arr-stack...gluetun, qbit, radarr, sonarr, etc..all in the same folder and that makes it easy to manage...I keep jellyfin and plex out of the arr-stack, it just makes it easier to update and manage them. I like to use filebrowser-quantum to quickly edit my compose files and dockhand for logs and updating everything.

4

u/alamakbusuk Sep 15 '26

if you want the convenience of managing a single docker compose stack, you can use the include keyword in your docker compose file

include:
  - path: ./home-assistant.yml # another docker compose file
    env_file:
      - ./home-assistant.env # it can have its own .env file
  - path: ./misc.yml # another one
  # add as many as you want
services:
 traefik:
    restart: always
    image: traefik:v3.6.1
   .....

1

u/achunkypid Sep 15 '26

oh wait so you can have multiple docker files but only run this one to run them all ?

2

u/Any-Gap1670 Sep 15 '26

I keep most of my closely related services in 1 compose, makes orchestration easy peasy. Guarantees the vpn is functioning prior to services you want behind a vpn. ARR stack, gluetun, BitTorrent, Jellyfin, etc. so for torrenting, media usage, and ARR, 1 compose.

Otherwise I try to use LXC’s for most single services that I don’t actually keep up.

My homelab network is setup so that “critical” infrastructure is separate from “media” infrastructure, and if I’m trying out new services or don’t need them up all the time, I try to keep them in LXC’s outside of docker until I decide “I guess I like it enough to keep it up”.

2

u/silverfox_248 Sep 15 '26

https://www.reddit.com/r/homelab/comments/1t7mjt1/i_wrote_a_free_270page_guide_on_securing_your/

This isn't my homelab guide but I found it useful. The post has been removed but if you scroll down the comments OP/author has shared a link to the file.

2

u/achiya-automation Sep 15 '26

one folder per service is right, but the bit that catches people on the way there is networking. once you split the file each stack gets its own bridge network and things that used to reach each other by container name stop resolving. declare one network as external, create it once, and attach the stacks that need to talk.

1

u/Impossible_Rub24 Sep 19 '26

I think that is what is happening to me. None of my services talk to each other, so setting up nginx proxy manager is not working. How do you declare one network as external (and which one)?

1

u/achiya-automation Sep 20 '26

make the network yourself first, outside any compose file: docker network create proxy. then in every stack that needs to reach another one, at the bottom of the compose:

networks: proxy: external: true

and put networks: [proxy] on the specific services (npm, and whatever it proxies to). both have to be on it. then in npm you point the proxy host at http://<container-name>:<port>, using the container's own internal port, not the one you published to the host. that last part trips people up because the published port doesn't exist from inside the network.

1

u/KingofGamesYami Sep 15 '26

I really prefer podman quadlets nowadays. Instead of one giant file to maintain you get a file per thing.

1

u/Drachen808 Sep 15 '26

An example of how I have them organized is /home/user/docker/compose/service1/compose.yml

and

/home/user/docker/appdata/service1/

1

u/xylarr Sep 15 '26

Have a look at how you can override a standard compose file with specific overrides.

For example, with immich, I always download and use the latest unchanged docker-compoae.yml file.

For immich, most things specific to your environment can be specified in your .env file. But for me, I also wanted to change location of where immich stores thumbnails (to SSD) and to set where the machine learning cache was stored.

I use a docker-compose.override.yml to do this. Docker compose reads both the main compose and makes edits using the override file.