5

What are the implications of exporting /var/lib/docker over NFS? The idea is to store the docker images in a server and export it to hosts which has limited memory to store and run containers. This would be useful to avoid having each host download and store it's own library of docker image. The hosts may make use of FS-Cache to limit the data transfer over network.

koshyg
  • 121
  • 2
  • 5

1 Answers1

8

The /var/lib/docker directory is designed to be exclusively accessed by a single daemon, and should never be shared with multiple daemons.

Having multiple daemons use the same /var/lib/docker can lead to many issues, and possible data corruption.

For example, the daemon keeps an in-memory state of which images are in use (by containers), and which ones not; multiple daemons using those image won't keep track of that (an image may be in use by another daemon), and remove the image while it's in use.

Docker also stores various other files in /var/lib/docker, such as a key/value store for user-defined networks, which is not designed to be accessed concurrently by multiple daemons.

thaJeztah
  • 27,738
  • 9
  • 73
  • 92
  • Appreciate the prompt response. – koshyg Mar 25 '16 at 06:25
  • A follow up question on your response. Isn't it good to separate image layers and states in docker daemons so that multiple daemons can share images, instead of downloading it every time while launching same type of containers in a separate daemon? Put another way, does docker provide any functionality to share downloaded images across daemons running on different hosts? – koshyg Apr 04 '16 at 00:35
  • No, docker doesn't support a shared graph storage, basically for the reasons above (an image that's not used on one host, could still be used on another host); there's experimental Suppprt for third-party storage driver plug-ins though; see https://github.com/docker/docker/blob/aabe39be01c70318af57159b235a4ddd8781051b/experimental/plugins_graphdriver.md, for example, here's a ceph driver plugin; https://github.com/hustcat/docker-graph-driver – thaJeztah Apr 04 '16 at 01:50
  • Thanks. I shall check it out. – koshyg Apr 06 '16 at 18:09