3

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.

Warren Seine
  • 2,103
  • 1
  • 23
  • 36

2 Answers2

3

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.
Dharmit
  • 4,958
  • 2
  • 22
  • 28
  • Ok, it might be the solution, though it's still moving the whole Docker runtime, not just my volume. – Warren Seine Jul 31 '15 at 14:00
  • I found some complementary information [here](http://stackoverflow.com/questions/24309526/how-to-change-the-docker-image-installation-directory). – Warren Seine Jul 31 '15 at 14:01
  • 1
    I don't think you can move just the volume part of it to `/data` and still keep the runtime under `/var/lib/docker`. – Dharmit Jul 31 '15 at 14:02
  • 2
    I'm pretty sure the way docker works means you can't control where volumes go at a container level like that. – Sobrique Jul 31 '15 at 14:02
-1

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.

Sobrique
  • 52,335
  • 6
  • 56
  • 99
  • That's not what I'm asking. I don't want a shared directory, I just want a different location for my `vfs` volume. – Warren Seine Jul 31 '15 at 13:26
  • 1
    Ah, ok. I think that's something that'd be more related to your docker installation on this host, rather than individual containers/images, so I'd be thinking either symlink or mount `/data` into that location. – Sobrique Jul 31 '15 at 13:37
  • 1
    Maybe there's something to that, but the other answer looks much more promising. – Warren Seine Jul 31 '15 at 13:59