Portainer News and Blog

How To: Mount a CIFS share to a container in Docker Desktop

Written by Neil Cresswell, CEO | March 27, 2023

So I had someone ask me today, "How do i mount a remote CIFS share to a container running on Docker Desktop on Windows"... and to be honest, i had no idea... so i tested it..

First problem, Docker Desktop uses an alpine based WSL2 image, and this image is missing the cifs-utils package.. this needs to be installed

Open the Windows command prompt, and type "wsl --distribution docker-desktop"

You will then get a console into the WSL2 instance.

Then type "apk add cifs-utils" and wait for it to install

Now switch back to Docker Desktop, and using the Portainer Extension, you can define a volume that maps to the CIFS share as follows:

Note: substitute the IP address of your CIFS target (dont use dns name as that just adds complexity), and add in a username and password that has access to the CIFS share.

See the volume is created. Dont worry about the mount point location, thats just where Docker mounts the CIFS share into.

Now you can add this volume to a container..

Then click "deploy container"

Once the container is deployed, open a console into the container to validate the share..

Compare against the share itself..

 

Success.. works perfectly.

So this is how you attach a CIFS share to a container inside Docker Desktop for Windows (using Portainer Extension).

Neil