I’m hosting a few services using docker. For something like an openstreetmap tileserver, I’d like it to remain on my SSD because high speed improves performance, and the directory is unlikely to grow and fill the drive.

For other services like NextCloud, speed isn’t as important as storage size, so I might want it on a larger HDD raid.

I know it’s trivial to move the volumes directory to wherever, but can I move some volumes to one directory and some volumes to another?

  • Matt The Horwood@lemmy.horwood.cloud
    link
    fedilink
    English
    arrow-up
    6
    ·
    3 days ago

    If you use a volume, you can mount that anywhere.

    volumes:
      lemmy_pgsql:
        driver: local
        driver_opts:
          type: none
          o: bind
          device: '/mnt/data/lemmy/pgsql'
    

    Then in your service add a volume

        volumes:
          - lemmy_pgsql:/var/lib/postgresql/data:Z
    
    • ikidd@lemmy.world
      link
      fedilink
      English
      arrow-up
      4
      ·
      2 days ago

      Is there any advantage to bind mounting that way? I’ve only ever done it by specifying the path directly in the container, usually ./data:data or some such. Never had a problem with it.

        • ikidd@lemmy.world
          link
          fedilink
          English
          arrow-up
          3
          ·
          2 days ago

          Well, I know you can define volumes for other filesystem drivers, but with bind mounts, you don’t need to define the bind mount as you do, you can just specify the path directly in the container volumes and it will bind mount it. I was just wondering if there was any actual benefit to defining the volume manually over the simple way.

          • Matt The Horwood@lemmy.horwood.cloud
            link
            fedilink
            English
            arrow-up
            5
            ·
            2 days ago

            In my case I need to use a named volume for docker swarm, also I can reuse a named volume in other services. If your not using swarm then just a bind mount should be fine

            • ikidd@lemmy.world
              link
              fedilink
              English
              arrow-up
              1
              ·
              2 days ago

              OK, yah, that’s good point about swarms. I’ve generally not used any swarmed filesystem stuff where I needed persistence, just shared databases, so it hasn’t come up.