Docker – Mount Windows Network Share Inside Container [duplicate]
This question already has an answer here:
Mount SMB/CIFS share within a Docker container
2 Solutions collect form web for “Docker – Mount Windows Network Share Inside Container [duplicate]”
You are correct that you can only use
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
/ 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.