Monday, 22 May 2017

Allowing docker write access to volumes mounted on NFS

My development machine (mydev) mounts several directories which are on an NFS mounted filesystem

When I run docker I wish to be able to access and write to the NFS filesystem.

The following is a brief technique:

Inside the dockerfile:

RUN useradd -m -d /home/mydocker mydocker; echo 'usermod -u $HOST_UID mydocker' >> ~/.bash_profile

# what order does this run in?
ENTRYPOINT source /root/.bash_profile && su - mydocker && /bin/bash

If I we to run docker with:

[me@mydev]$ sudo docker -i run -e"HOST_UID=`id -u`" -v /some/nfs/drive:/var/local/drive -t /bin/bash

Then mydocker will have the same uid as the user I ran the sudo with and should be able to access the NFS drive in the same was as the native user (me).

No comments:

Post a Comment