Search code examples
dockersambacifs

Can a windows network share be mounted within a docker container?


Google is turning up some bizarre results, including questions here at SO. I am aware that this isn't a supported/recommended configuration. However is this even an undocumented option?

If it is difficult, it's something I'll continue to pursue, but if it's just impossible and docker is engineered that way, I'll give up.


Solution

  • Volume plugins are your answer. Storage is a bit of an involved topic but I am currently running a mix of NFS / Gluster and SMB SAN hosted storage.

    Have a read and test out different plugins:
    https://docs.docker.com/engine/extend/plugins_volume/

    Docker NFS, AWS EFS & Samba/CIFS Volume Plugin:
    https://github.com/ContainX/docker-volume-netshare

    Manually, you first create the Docker volume, specifying the driver:

    $ docker volume create --driver=flocker volumename
    

    Then you launch your container and mount the created volume:

    $ docker container run -it --volume volumename:/data busybox sh
    

    Here is an example of how the Gluster plugin was used in the Compose file:

    volumes:
      CreatedVolumeName:
        driver: sapk/plugin-gluster
        driver_opts:
          voluri: ip_of_export:<export path>
    services:
      service_name:
        image: image_name
        networks:
          - my_net
        volumes:
          - CreatedVolumeName:/etc (some internal mount in the container)