rdupz
rdupz

Reputation: 2313

Where should live docker volumes on the host?

On the host side, should all the mount points be located in the same location? Or should they reflect the locations which are inside the containers?

For example, what is the best place to mount /var/jenkins_home on the host side in order to be consistent with its Unix filesystem?

Upvotes: 2

Views: 128

Answers (2)

johnharris85
johnharris85

Reputation: 18966

Rather than using explicit host:container mounts, consider using named volumes. This has several benefits:

  • They can be shared easily into other containers
  • They are host-agnostic (if you don't have the specific mount on that machine, it will fail)
  • They can be managed as first-class citizens in the Docker world (docker volume)
  • You don't have to worry about where to put them on your host ;)

Upvotes: 0

Shibashis
Shibashis

Reputation: 8411

It absolutely depends on you where you want to mount the volume on the host. Just don't map it to any system file locations.

In my opinion the volumes reflecting the locations inside the container is not a great idea since you will have many containers, and all will have similar file system structure, so you will never be able to isolate container writes.

With jenkins, since the official Jenkins docker image runs with user "jenkins", it will be not a bad idea for you to create jenkins user on the host and map /home/jenkins on the host to /var/jenkins_home on the container.

Upvotes: 1

Related Questions