Warren Seine
Warren Seine

Reputation: 2449

Creating a Docker volume at a specific location

Can I tell Docker to create a volume at a specific location on the host machine?

The host machine has some storage restrictions and I'd like the volume to be stored in /data instead of /var/lib/docker/vfs/dir/.

This isn't even mentioned in the documentation so I suspect I misunderstood something.

Upvotes: 3

Views: 5657

Answers (2)

Dharmit
Dharmit

Reputation: 5918

Do you want to use a different directory than the default /var/lib/docker as Docker runtime? You can do this by starting docker daemon with -g option and path to the directory of your choice. From the man page:

-g, --graph=""
     Path to use as the root of the Docker runtime. Default is /var/lib/docker.

Upvotes: 2

Sobrique
Sobrique

Reputation: 53508

When firing up your container with "docker run":

 docker run -v /data/some_directory:/mount/location/in/your/container your_docker_image

You cannot do this in the same way via Dockerfile because of portability.

Upvotes: 0

Related Questions