springloaded
springloaded

Reputation: 1079

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?

Upvotes: 9

Views: 4932

Answers (1)

programmerq
programmerq

Reputation: 6534

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)

Upvotes: 13

Related Questions