Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store a specific named docker volume at a specific location without changing the default?

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?

like image 381
springloaded Avatar asked Dec 13 '17 03:12

springloaded


1 Answers

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)

like image 158
programmerq Avatar answered Sep 27 '22 19:09

programmerq