Docker Community Forums

Share and learn in the Docker community.

How to access the NFS share of container

docker

(Labins) #1

I have shared a file via NFS using docker container. Now, How can other host in the network can access this NFS share which is being shared by docker container.

--------DOCKER FILE CONTENT-----------------
FROM rhel6:latest
MAINTAINER unixboy
#Add repo to docker image and allow to to install necessary rpms
COPY my.repo /etc/yum.repos.d/
RUN yum -y install git nfs-utils net-tools wget bind-utils
RUN mkdir -p /codeshare
COPY hc.sh /codeshare
RUN echo "/codeshare/ *(ro,sync)" >> /etc/exports
EXPOSE 2049 111
ENTRYPOINT service rpcbind start && service nfs start && bash

--------Starting the container---------------
[Dev root @ dockerhost /home/txmxk/container]
# docker run -it --privileged=true -P -p 111 -p 2049 --name myhc 5f95196c3be5 /bin/bash
Starting rpcbind:                                          [  OK  ]
FATAL: Could not load /lib/modules/3.10.0-693.11.6.el7.x86_64/modules.dep: No such file or directory
Starting NFS services:                                     [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
[root@1aad3c624e57 /]#

[root@1aad3c624e57 /]# showmount -e
Export list for 1aad3c624e57:
/codeshare/hc.sh *

=============INSPECTING DOCKER CONTAINER===================
[Dev root @ dockerhost ~]
# docker inspect 1aad3c624e57

-----Excerpt---------------------
 "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "d53bd20ca5e608c4a2379a266bde73f02ebf3ab91a30180d021885def657d517",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "111/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32812"
                    }
                ],
                "2049/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "32811"
                    }
                ]

------------------
When I executed shomount command as shown from other node to access the container NFS share, i got following error:

[Dev root @ node01 ~]
# showmount -e dockerhost:328212
clnt_create: RPC: Unknown host