Docker Community Forums

Share and learn in the Docker community.

Store images in non-default locations

I’m working extensively with docker to manage various build environments for different projects. Some of the images I’m using are very large. Right now docker is configured with the default location (/var/lib/docker/ on my Linux host). Is there a way to configure it to use different locations, such that some images are located / stored in a different (possibly NFS-mounted) file system ?


You can change your docker root folder location. Make sure to shutdown your docker service, copy the content of the old root foler into the new folder and start the service afterwards.


  "data-root": "/var/lib/docker"

Though, I can image that overlayfs will not work when the data is stored on a remote file system like nfs or cifs.

Thanks. I know I can change the default location. What I’m asking is how to use a non-default location. That is, how to define a location specifically for some images, while keeping all others in the default location.

Seems my example was unclear: just replace the default path in my example with a path of your choosing. This will be an all or nothing setting - without any sort of cherry picking. sorry.

Just to be entirely clear: Are you saying docker does not support such a fine-grained control of per-image storage location ? Are merely that your suggestion above wouldn’t allow that ?

Like I wrote: this is an all or nothing setting.

The only exceptions are docker volumes: you can point them to whatever location you want (local/cifs/nfs) or to whatever volume plugin you install.

Apologies to resurrect the old thread again, so for fine grained control, would you recommend modifying /etc/docker/daemon.json file, everytime with a predefined path (preferably via scripts) and this would require stopping and starting the docker service right? (again preferrably using scripts) Just asking if this approach would be fine . I understand the possibilities of failure over this approach, but would it work? Please let me know your thoughts