All docker files look something like this

services:
  service_name:
    image: author/project:latest
    container_name: service_name
    volumes:
      - service_data:/app/data/

volumes:
  service_data:

Yes, this makes the data to persist, but it creates a directory with a random name inside /var/lib/docker/volumes/
This makes it really hard to actually have ownership of the data of the service (for example to create backups, or to migrate to another host)

Why is it standard practice to use this instead of having a directory mounted inside at the same level you have your docker-compose.yml?
Like this - ./service_data:/app/data

  • rumba@lemmy.zip
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 days ago

    I think the primary reason is that it was designed to be a larger install than what most of you are using.

    If you’re doing a giant k8s, with a bunch of pods that come and go dynamically, portability, consistency, and management are key. And for the most part you’re not handling long-term persistent data the same way as you do when you’re just installing containers on your home lab or development environment.

    But since most people don’t have this constraints, blind mounts make a hell of a lot more sense if you were only running one server in one location.