Docker – Mount Windows Network Share Inside Container [duplicate]

This question already has an answer here:

  • Mount SMB/CIFS share within a Docker container

    2 answers

  • How to add dynamic file to docker container
  • WSO2-APIM (v1.9.1) Running from Docker, cant create a new API using swagger URL
  • Dockerfile necessary? Advisable?
  • Possible to make incremental checkpoints CRIU
  • something confused with docker
  • Docker nginx proxy works with docker-compose v1, but not v2?
  • Docker in a Parallels' Virtual Windows 10 Pro Machine
  • Alternating provisioning with Vagrant
  • How to mount a directory inside a docker container on linux host
  • Connect to MySQL in a docker container (Vagrant on Windows/VirtualBox)
  • How to Copy file to stopped docker container
  • Airbnb Airflow using all system resources
  • 2 Solutions collect form web for “Docker – Mount Windows Network Share Inside Container [duplicate]”

    You are correct that you can only use --privileged during docker run. You cannot perform mount operations without --privileged, ergo, you cannot perform mount operations during the docker build process.

    This is probably by design: the goal is that a Dockerfile is largely self contained; anyone should be able to use your Dockerfile and other contents in the same directory to generate the same image; linking things to an external mount would violate this restriction.

    However, your question says that you have an application that needs to read some data from a share so it’s not clear why you need the share mounted during docker build. It sounds like you would be better off building an image that will launch your application as part of docker run, and possibly use docker volumes to access the share rather than attempting to mount it inside the container.

    Haven’t used Docker so this may not apply, however if you list your share in /etc/fstab and include the user option, then you can allow unprivileged users to mount it, e.g. from your script.

    Also bear in mind that mkdir -p "//myshare/folder name" is a semi-invalid path – most shells will condense the // into / so you may not have access to a folder called /myshare/folder name since the root directory of a Linux system is not normally where you put files. You might have better success using /mnt/myshare-foldername or similar instead.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.