How you manage the state of your docker container services? reddit / selfhosted ---------------------------------------------------------------------- vazma · 2023-12-16 12:42 In my home I run few services using docker + portainer which as usually a docker compose is mounting a local path as state to each container. i.e $HOME/$SERVICE/DATA:/DATA I am re-designing about this configuration and I am thinking to use my NAS as the storage server which I will create a volume mounting to a specific DIR in my NAS and keep the config there safe and redundant. Do you have any examples / best practises around this topic? ---------------------------------------------------------------------- jenishngl · 2023-12-16 13:10 Try coolify. I have been using it for all app hosting with and without docker. Everything is extremely easy. ---------------------------------------------------------------------- pixelvengeur · 2023-12-16 13:13 I don't have any 'best practices' to recommend, but the way you want to go about it is how I do it. One thing you should keep in mind is that if power goes out, and your containers boot before your NAS finishes booting up, the shares won't be there and thus deployment will fail. You will have to either reboot the machine that hosts the containers, restart the docker service, or hopefully only need a `sudo mount -a` to mount the network volumes to the machine. You could try messing with systemd and delaying the start of the docker service until the network shares are mounted, but I haven't found great luck with that personally. ---------------------------------------------------------------------- thekrautboy · 2023-12-16 13:15 Storing Docker volumes directly on a NAS might impact performance of the container. Ymmv, depends on a lot of factors. Try it out. Docker has storage drivers for SMB and NFS builtin. ---------------------------------------------------------------------- gongarher · 2023-12-16 16:31 I have automated the solution of that issue with a simple bash script: https://github.com/gongarher/telegram-automount-disks It notifies via Telegram when a disk has been unmounted :) ---------------------------------------------------------------------- tenekev · 2023-12-16 17:44 My bulk data is on a NAS - Media, documents, etc. Appdata - stuff that is generated and often accessed by the containers like DBs, metadata, thumbs, etc, is stored on an SSD that is part of the Docker machine. The file structure is similar to yours - `Appdata/$SERVICE/data` I've always kept it as a separate hardware device that I can easily swap, duplicate, etc. The config files - docker-compose.yml, .env and other config files required by services (Like traefik's static config or prometheus's prometheus.yml or authelia's configuration.yml) are stored in a separate config directory. Directory structure is `Config/$STACK_NAME/` or `Config/$SERVICE_NAME/`. These are both docker-compose driven but one is concerned with a topic like `stack_media` while the other is concerned with a service like `service_immich`. Just a simple way to order things when you have 100s of stacks. The config directory is sent to a Gitea repo. Portainer pulls from that repo and applies changes. This way I maintain version history too. ---------------------------------------------------------------------- schklom · 2023-12-16 20:59 I would simply add a `@reboot chronic /path/script.bash` crontab script ``` sleep 60 sudo mount -a sudo systemctl restart docker.service sudo docker compose -f /path/docker-compose.yaml -e /path/.env up -d ``` Dirty, but should always work. `chronic` emails you if the cron job fails and you have set up an email account ---------------------------------------------------------------------- kindrudekid · 2023-12-16 23:01 All the other solution is way too complicated and or home brew…. I just use systemctl method: sudo systemctl edit docker # add the below contents [Unit] Requires=mnt-media.mount After=mnt-media.mount Description=Wait for NFS mounts to be loaded before starting docker. To find the mount systemctl name: systemctl list-units -t mount --all ---------------------------------------------------------------------- Frozen_Gecko · 2023-12-16 23:08 This is brilliant, thank you ---------------------------------------------------------------------- MDSExpro · 2023-12-17 08:54 By using Kubernetes.