Hi,
I’m using docker-compose to host all my server services (jellyfin, qbittorrent, sonarr, etc.). I’ve recently grouped some of them into individual categories and then merged the individual docker-compose.yml file I had for each service into one per category. But is there actually any reason for not keeping them together?
The reason why is I’ve started configuring homepage and thought to myself “wouldn’t it be cool if instead of giving the server IP each time (per configured service in homepage) I’d just use the service name?” (AFAIK this only works if the containers are all in the same file).
I have a folder that all my docker services are in. Inside the folder is a folder for each discrete service and within that folder is a unique compose file necessary to run the service. Also in the folder is all the storage folders for that service so it’s completely portable, move the folder to any server and run it and you’re golden. I shut down all the services with a script then I can just tar the whole docker folder and every service and its data is backed up and portable.
In case anyone cares here is my script, I use this for backups or shutting down the server.
#!/bin/bash logger "Stopping Docker compose services" services=(/home/user/docker/*) # This creates an array of the full paths to all subdirs #the last entry in this array is always blank line, hence the minus 1 in the for loop count below for ((i=0; i<=(${#services[@]}-1); i++)) do docker compose -f ${services[i]}/docker-compose.yml down & done #wait for all the background commands to finish wait
Could you share your script?
Thanks!
Does portainer just work?
To answer my own question, yes, yes it does. Should’ve done this ages ago…
I personally don’t. It is just messier. I only group things that belong together, like a webserver+database, torrentclient+vpn and so on.
I’ll be the opposite of everyone I guess I have all my services in one compose file. Never had an issue with it. Why I have no exposed ports and everything is accessed through a reverse proxy, and the big one it’s easy to just go docker compose and have them all come up or down.
Same for me, it all mostly started from the desire to have a single MariaDB and Postgresql container holding all the databases. Not sure if I could achieve the same result with different compose files, perhaps I can, bit never had the need.
I actually find my setup super comfortable to use
For simplicity sake alone I would say No. As long as services don’t share infrastructure (eg. a database) you shouldn’t mix them so you have an easier time updating your scripts.
Another point is handling stacks. When you create dockers via compose you are not supposed to touch them individually. Collecting them all, or even just in categories, muddies that concept, since you have unrelated services grouped in a single stack and would need to update/up/down/… them all even if you just needed that for a single one.
Lastly networks. Usually you’d add networks to your stacks to isolate their respective Backend into closed networks, with only the exposing container (eg. a web frontend) being in the publicly available network to increase security and avoid side effects.
So right now I have a single compose file with a file structure like this:
docker/ ├─ compose/ │ ├─ docker-compose.yml ├─ config/ │ ├─ service1/ │ ├─ service2/
Would you in that case use a structure like the following?
docker/ ├─ service1/ │ ├─ config/ │ ├─ docker-compose.yml ├─ service2/ │ ├─ config/ │ ├─ docker-compose.yml
Or a different folder structure?
deleted by creator