Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Selfhosted
  3. Does it ever make sense/is it possible to move certain docker volumes to another physical volume, but not all?

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

Scheduled Pinned Locked Moved Selfhosted
selfhosted
18 Posts 11 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C [email protected]

    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?

    L This user is from outside of this forum
    L This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #3

    I have several NFS shares that host multiple docker volumes. So yes.

    1 Reply Last reply
    0
    • C [email protected]

      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?

      dave@lemmy.nzD This user is from outside of this forum
      dave@lemmy.nzD This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #4

      I don't know if this is naughty but I use bind mounts for everything, and docker compose to keep it all together.

      You can map directories or even individual files to directories/files on the host computer.

      Normally I make a directory for the service then map all volumes inside a ./data directory or something like that. But you could easily bind to different directories. For example for photoprism I mount my photos from a data drive for it to access, mount the main data/database to a directory that gets backed up, and mount the cache to a directory that doesn't get backed up.

      S T C 3 Replies Last reply
      0
      • dave@lemmy.nzD [email protected]

        I don't know if this is naughty but I use bind mounts for everything, and docker compose to keep it all together.

        You can map directories or even individual files to directories/files on the host computer.

        Normally I make a directory for the service then map all volumes inside a ./data directory or something like that. But you could easily bind to different directories. For example for photoprism I mount my photos from a data drive for it to access, mount the main data/database to a directory that gets backed up, and mount the cache to a directory that doesn't get backed up.

        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #5

        Same, I don't let Docker manage volumes for anything. If I need it to be persistent I bind mount it to a subdirectory of the container itself. It makes backups so much easier as well since you can just stop all containers, backup everything in ~/docker or wherever you put all of your compose files and volumes, and then restart them all.

        dave@lemmy.nzD 1 Reply Last reply
        0
        • dave@lemmy.nzD [email protected]

          I don't know if this is naughty but I use bind mounts for everything, and docker compose to keep it all together.

          You can map directories or even individual files to directories/files on the host computer.

          Normally I make a directory for the service then map all volumes inside a ./data directory or something like that. But you could easily bind to different directories. For example for photoprism I mount my photos from a data drive for it to access, mount the main data/database to a directory that gets backed up, and mount the cache to a directory that doesn't get backed up.

          T This user is from outside of this forum
          T This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #6

          I do that, until some container has permissions issues.
          I tinker, try and fix it, give up and use a volume. Or I fix it, but it never seems to be the same fix

          dave@lemmy.nzD 1 Reply Last reply
          0
          • T [email protected]

            I do that, until some container has permissions issues.
            I tinker, try and fix it, give up and use a volume. Or I fix it, but it never seems to be the same fix

            dave@lemmy.nzD This user is from outside of this forum
            dave@lemmy.nzD This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #7

            I occasionally have had permissions issues but I tend to be able to fix them. Normally it's just a matter of deleting the files on the host and letting the container create them, though it doesn't always work it usually does.

            1 Reply Last reply
            0
            • S [email protected]

              Same, I don't let Docker manage volumes for anything. If I need it to be persistent I bind mount it to a subdirectory of the container itself. It makes backups so much easier as well since you can just stop all containers, backup everything in ~/docker or wherever you put all of your compose files and volumes, and then restart them all.

              dave@lemmy.nzD This user is from outside of this forum
              dave@lemmy.nzD This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #8

              Yes that's what I do too!

              Overnight cron to stop containers, run borgmatic, then start the containers again.

              1 Reply Last reply
              0
              • dave@lemmy.nzD [email protected]

                I don't know if this is naughty but I use bind mounts for everything, and docker compose to keep it all together.

                You can map directories or even individual files to directories/files on the host computer.

                Normally I make a directory for the service then map all volumes inside a ./data directory or something like that. But you could easily bind to different directories. For example for photoprism I mount my photos from a data drive for it to access, mount the main data/database to a directory that gets backed up, and mount the cache to a directory that doesn't get backed up.

                C This user is from outside of this forum
                C This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #9

                I've never not used bind mounts. That data is persistent. Nonpersistent data is fine on docker volumes.

                dave@lemmy.nzD 1 Reply Last reply
                0
                • C [email protected]

                  I've never not used bind mounts. That data is persistent. Nonpersistent data is fine on docker volumes.

                  dave@lemmy.nzD This user is from outside of this forum
                  dave@lemmy.nzD This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #10

                  Docker wants you to use volumes. That data is persistent too. They say volumes are much easier to backup. I disagree, I much prefer the bind mounts, especially when it comes to selective backups.

                  K 1 Reply Last reply
                  0
                  • C [email protected]

                    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?

                    mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                    mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #11

                    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.worldI 1 Reply Last reply
                    0
                    • dave@lemmy.nzD [email protected]

                      Docker wants you to use volumes. That data is persistent too. They say volumes are much easier to backup. I disagree, I much prefer the bind mounts, especially when it comes to selective backups.

                      K This user is from outside of this forum
                      K This user is from outside of this forum
                      [email protected]
                      wrote on last edited by
                      #12

                      Volumes are horrible, how would I easily edit a config file of the programm running inside, if the container deosnt even start.

                      Bind mounts + ZFS datasets are the way to go.

                      1 Reply Last reply
                      0
                      • mhzawadi@lemmy.horwood.cloudM [email protected]

                        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.worldI This user is from outside of this forum
                        ikidd@lemmy.worldI This user is from outside of this forum
                        [email protected]
                        wrote on last edited by
                        #13

                        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.

                        mhzawadi@lemmy.horwood.cloudM 1 Reply Last reply
                        0
                        • C [email protected]

                          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?

                          M This user is from outside of this forum
                          M This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #14

                          No idea. I personally use PVs and PVCs with k3s and it's trivial there with some downtime

                          1 Reply Last reply
                          0
                          • ikidd@lemmy.worldI [email protected]

                            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.

                            mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                            mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #15

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

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

                            ikidd@lemmy.worldI 1 Reply Last reply
                            0
                            • mhzawadi@lemmy.horwood.cloudM [email protected]

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

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

                              ikidd@lemmy.worldI This user is from outside of this forum
                              ikidd@lemmy.worldI This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #16

                              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.

                              mhzawadi@lemmy.horwood.cloudM 1 Reply Last reply
                              0
                              • ikidd@lemmy.worldI [email protected]

                                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.

                                mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                                mhzawadi@lemmy.horwood.cloudM This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #17

                                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.worldI 1 Reply Last reply
                                0
                                • mhzawadi@lemmy.horwood.cloudM [email protected]

                                  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.worldI This user is from outside of this forum
                                  ikidd@lemmy.worldI This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #18

                                  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.

                                  1 Reply Last reply
                                  0
                                  • System shared this topic on
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups