Docker | How do you store your data? reddit / selfhosted ---------------------------------------------------------------------- Ejz9 路 2023-12-15 23:05 Hello, My question is simple: Where do you guys store your data? Volumes? Bind Mounts? In my case, I store my data in bind mounts, all to a folder called "dockerDATA," but I can't help but notice that a folder called "data" exists at the root of my filesystem as well (ubuntu 22.04). Sometimes, when I create containers, I also notice that their default volume creation location is ".data/". Where is this, though? There is no hidden data folder in my root directory. Just a regular data folder, which I believe is managed by Portainer. Is this the other data folder? I mean, I have Portainer in use as well, so I think that may affect this. Beyond this, though, what do you think is better? Bind mounts or Docker-managed volumes, which I still don't actually understand how to create even after reading the documentation on volumes, How can I migrate my data to volumes? I know NextCloudAIO uses Docker volumes; do I just not put a "/" in front of the volume path to make it available in "/var/lib/docker/volumes..."? Also, a last consideration is that I use Kopia for backups. I run it in Docker, and I have it bind mount to my repository location. Would backing up everything in the Docker volumes path be better than what I currently do, which is backup "/dockerDATA" and the "/var/lib...volumes" path? Help is appreciated, and I would like to learn how to best do this. ---------------------------------------------------------------------- thekrautboy 路 2023-12-15 23:44 Fyi /r/Docker exists. > In my case, I store my data in bind mounts, all to a folder called "dockerDATA," but I can't help but notice that a folder called "data" exists at the root of my filesystem as well (ubuntu 22.04). Sometimes, when I create containers, I also notice that their default volume creation location is ".data/". Where is this, though? There is no hidden data folder in my root directory. Just a regular data folder, which I believe is managed by Portainer. Is this the other data folder? I mean, I have Portainer in use as well, so I think that may affect this. I cant make much sense of this, sorry. When the creator of a typical container image mentions in their documentation to mount `/data` to have persistent data through container restarts and removals, then this is what you should follow. Simply mounting `/data` inside the container to whatever you want on the Docker host side. That can be either a simple bind mount like in a compose: volumes: - /home/username/dockerstuff/thiscontainer/data:/data If you then have another container that also uses `/data` inside the container, this doesnt matter at all and doesnt conflict with the first container. You simply mount that path to another one on the Docker host like: volumes: - /home/username/dockerstuff/anothercontainer/data:/data Do not use the same path on the host for multiple containers. Very simply. And it should be obvious. > Beyond this, though, what do you think is better? Bind mounts or Docker-managed volumes That depends. Sometimes you want to mount something in a very specific path on the host, then often the simple bind mount is the only way. Other times you might struggle with correct permissions inside a volume, then using a actual volume for storage might be better for you because then Docker manages the permissions inside that volume for you. ---------------------------------------------------------------------- adamshand 路 2023-12-16 01:23 I used to always use bind mounts. Every application/stack gets a folder with a single compose file and all of it's volumes are bind mounted there, eg. ``` /srv /memos /app /docker-compose.yml ``` This works and is easy to understand and backup. It is how I would still do it for a single Docker host. Tangent ... I'm now in the process of trying to move everything to a Docker Swarm managed by CapRover. I want to be able to move containers between hosts and to reboot a server without breaking services. However containers which require persistent storage are trickier. All my media services are stored on a NAS and I NFS mount them to all of my homelab servers. Containers then bind mount whatever portion of the media folder they require (books, music etc). However you can't run SQLite databases off of NFS and for for my VPS swarm I don't have an NFS server. For this, I'm experimenting with using the Docker Rclone plugin to mount S3 buckets inside the container. So far this seems to be working well. CapRover only supports a subset of docker-compose and it's a bit annoying to setup. I have a feature request in to update their [one- click-application template language to support service update overrides](https://github.com/caprover/caprover/issues/1960) which will make it easier. Will see how this goes. 馃馃徎 ---------------------------------------------------------------------- timeister 路 2023-12-16 02:28 Some I store forward, and some I store after ---------------------------------------------------------------------- -ShavingPrivateRyan- 路 2023-12-16 05:56 You should just jump into k3s with longhorn ---------------------------------------------------------------------- adamshand 路 2023-12-16 06:17 Yeah, I've been wondering about that. Everything I've read is that even K3S is a PITA ... is it worth it? ---------------------------------------------------------------------- Spuxilet 路 2023-12-16 12:13 I store everything important in docker volumes, because they are superior to bind mounts. Bind mounts have limited functionality compared to volumes. This is why i store things like movies and tv shows in bind mounts. I do not care about them. I sync whole docker root folder to my laptop from my server and to external drive. Everything is backed up this way. Everything about dockers are in there. ---------------------------------------------------------------------- Ejz9 路 2023-12-16 14:46 Okay and how do I make sure it鈥檚 creating a volume in Portainer when deploying a stack vs making a bind mount? This is what I was under the impression of when looking at the documentation. So I鈥檒l make the switch between today/tomorrow.