Docker container to NAS Storage

I'm trying to mount the storage volume to inside the container. like the linux i given the below command

**mount 10.#.##.###:/nvol1 /tmp**

this gives "Access denied" error, i have added the Container and host IP to storage to allow the traffic from the Container & the host server. But i cannot mount the storage volume in the container ? Am i missing something ? i'm using Centos Operating System.

Edit Note: I have already mount the storage to the Docker host successfully and made the communication between the host file system and the container. however this new test case seeking directly mount the storage volume on the container not on the Docker host.


You won't be able to run a mount command from inside of the container without disabling some of the isolation that docker provides (otherwise an untrusted app could mount the host root filesystem and escape). Docker prevents this by removing various capabilities from the root user inside the container.

For an NFS mount, you would typically mount this as a volume into the container in one of two ways:

  • Mount the NFS directory on the host, and map the host directory into the container. This allows you to manage the volume directly on the host in addition to inside the container.

  • Mount the NFS directory as a volume directly into the container.

  • For option 2, you can define the volume with something like:

    $ docker volume create --driver local 
        --opt type=nfs 
        --opt o=addr=10.1.23.123,rw 
        --opt device=:/nvol1 
        nvol1
    
    $ docker run -v nvol1:/tmp your_image
    

    Edit: to skip the docker volume create step, you can do this from a run command with the --mount option:

    $ docker run -it --rm 
      --mount type=volume,dst=/container/path,volume-driver=local,volume-opt=type=nfs,volume-opt=o=addr=192.168.1.1,volume-opt=device=:/host/path 
      foo
    
    链接地址: http://www.djcxy.com/p/18250.html

    上一篇: Docker多主机(Swarm)持久性存储

    下一篇: Docker容器到NAS存储