mount error(13): Permission denied - In docker/kubernetes

8/3/2018

I'm fairly new to kubernetes and docker, so be patient with me.

I am trying to mount a Windows share in linux which is contained in docker, which is a kubernetes pod.

I managed to get all the correct permissions in kubernetes and docker to mount the share manually. However I need this to be done via the Dockerfile, since it needs to be automated.

This is my Dockerfile:

WORKDIR /app
COPY ./start-script.sh ./start-script.sh

RUN apt-get update && apt-get install -y cifs-utils
RUN mkdir Windows-Share
# RUN mount.cifs <Window share folder> /app/Windows-Share/ -o username=<username>,password=<password>,domain=<domain>

ENTRYPOINT ["bash", "./start-script.sh"]

Here is my start-script.sh:

#!/bin/bash
mount.cifs <Window share folder> /app/Windows-Share/ -o username=<username>,password=<password>,domain=<domain>
exec dotnet <dotnet dll>

Now it should be noted that I don't have access to any of the docker commands, they are all handled by kubernetes. After kubernetes creates the pod the logs will show:

mount error(13): Permission denied

Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

This confuses me because if I log into the kubernetes pod and run the mount command manually it mounts fine. What am I missing?

-- kumar5
cifs
docker
kubernetes
mount
windows-share

1 Answer

8/3/2018

The right approach tends to be to provide appropriate storage setup outside your container, rather than trying to mount things in your container. In the specific case of Kubernetes this means setting up appropriate Volumes and then mounting them in your pod spec.

There's not an out-of-the-box SMB/CIFS Volume driver, but it looks like Microsoft publishes Kubernetes storage plugins that can help.

-- David Maze
Source: StackOverflow