Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Advantages of creating NFS-backed volume, vs bind mounting volume mounted on the host?

Tags:

docker

Let's say I have a Docker container than needs to read and write to an NFS share. There are at least two approaches:

  • Mounting the NFS share on the host, and then bind-mounting the share on the volume, e.g. mount the share at /my/share and then running the container with -v /my/share:/my/data.
  • Creating an NFS-backed Docker volume, passing --opt type=nfs in addition to other parameters needed to identify the share, e.g. --opt o=addr=192.168.1.1,rw etc.

Are there any significant advantages using the seconds approach (except ease-of-use) and more specifically, are there any risks or perils connected with the first one?

This question assumes that approach 1 is already used, and that there is a certain cost associated with changing it.

like image 244
Hannes Petri Avatar asked Dec 19 '25 23:12

Hannes Petri


1 Answers

The most obvious advantage would be that: By directly using the NFS backed volume, you can decouple the container and the host.So you can run the same configuration everywhere In case of bind mounting, you are coupling both. So you will have to change your configuration when you move to a different server.

like image 96
GustavoS Avatar answered Dec 22 '25 15:12

GustavoS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!