9

I would like to create a named volume for one of my containers.

This container will need a lot more storage than other containers I run, so I would like to store that particular volume on a different disk that has lots of free space.

I still want the other volumes on the default disk, only that one named volume should go on another disk.

I don't want to use a bind mount because it will make backing up and migrating more complicated.

The only option I can think of is to manually move the volume after it is created (while the container is stopped), and create a symlink from its original location in /var/lib/docker/... to the new location on the other hard drive. This is very manual though, which leads me to think there must be a better way.

What is the recommended way of achieving this?

springloaded
  • 1,079
  • 2
  • 13
  • 23
  • https://github.com/projectatomic/docker-lvm-plugin might help, not sure how reliable it is – Matt Dec 13 '17 at 08:59

1 Answers1

12

Use the local volume driver:

docker volume create -d local -o type=none -o o=bind -o device=/host/path volname

(Taken from this github comment)

programmerq
  • 6,262
  • 25
  • 40
  • Does it make a `bind` type of mount, or a `volume` type of mount? Is it different than `docker run -v /host/path:/mypath ...`? – springloaded Dec 14 '17 at 02:11
  • Technically, all volumes are bind mounts. This is a named volume using the local driver, which allows you to specify any mount type possible, including _bind mounts_ This seems like what you need since you want a named volume, but not a bind mount/host mount where you specify the host location on the -v argument. – programmerq Dec 14 '17 at 02:18