Skip Navigation

Does it ever make sense/is it possible to move certain docker volumes to another physical volume, but not all?

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?

18 comments
  • 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
    
      
    • 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.

      • with the way I do it, you can also use NFS as a backend

        https://docs.docker.com/reference/compose-file/volumes/

        • 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.

          • 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

            • 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.

18 comments