Mounting nfs shares inside docker container

Starting from docker 17.06, you can mount NFS shares to the container directly when you run it, without the need of extra capabilities export NFS_VOL_NAME=mynfs export NFS_LOCAL_MNT=/mnt/mynfs export NFS_SERVER=my.nfs.server.com export NFS_SHARE=/my/server/path export NFS_OPTS=vers=4,soft docker run –mount \ “src=$NFS_VOL_NAME,dst=$NFS_LOCAL_MNT,volume-opt=device=:$NFS_SHARE,\”volume-opt=o=addr=$NFS_SERVER,$NFS_OPTS\”,type=volume,volume-driver=local,volume-opt=type=nfs” \ busybox ls $NFS_LOCAL_MNT Alternatively, you can create the volume before the container: docker volume create \ … Read more

Docker mount to folder overriding content

First of all, docker volumes or bind mounts behave like linux mounts. If the host volume/mount exists and contains files it will “override” whatever is in the container. If not the container files will be mirrored onto the host volume/mount and the container folder and the host will be in sync. In both cases editing … Read more

Permission denied on accessing host directory in Docker

See this Project Atomic blog post about Volumes and SELinux for the full story. Specifically: This got easier recently since Docker finally merged a patch which will be showing up in docker-1.7 (We have been carrying the patch in docker-1.6 on RHEL, CentOS, and Fedora). This patch adds support for “z” and “Z” as options … Read more

How to mount host volumes into docker containers in Dockerfile during build

It is not possible to use the VOLUME instruction to tell docker what to mount. That would seriously break portability. This instruction tells docker that content in those directories does not go in images and can be accessed from other containers using the –volumes-from command line parameter. You have to run the container using -v … Read more