Bobcares

Docker CIFS volume | An Introduction

by | Feb 4, 2023

Get ready to learn how to access CIFS volume in Docker. Our Docker Support team is here to lend a hand with your queries and issues.

 How to access CIFS volume in Docker

Today, we are going to take a look at how we can mount a CIFS share on the host OS with the right SELinux context as well as UID/GID mapping for Docker. This involves creating a Docker container that utilizes the CIFS share with read/write access.

Docker CIFS volume | An Introduction

However, the docker container does not have access to the CIFS mount point unless we mount the share with the appropriate SELinux security context. We can overcome this with the following context:

context=system_u:object_r:svirt_sandbox_fil_t:s0

CIFS, unlike NFS, carries our user authentication when mounting occurs. In other words, the files and directories at the CIFS mount point are owned by the same user or group. Interestingly, this may cause an issue if the user running the process in the container and the user of the CIFS mount are different. Fortunately, we can go resolve this issue by mounting the same CIFS share several times with different gid and uid arguments.

If you need help accessing a CIFS share from within a Docker container, these steps will help you out:

  1. First, we have to install the “cifs-utils” package in the container with this command:

    apt-get update && apt-get install cifs-utils

  2. Next, we have to create a mount point directory within the container as seen below:

    mkdir /mnt/cifs

  3. Then, we have to mount the CIFS share to the mount point directory as seen here:

    mount -t cifs //server-name/share-name /mnt/cifs -o username=,password=

    Furthermore, we can ensure the mount is persistent with the following line in the /etc/fstab file:

    //server-name/share-name /mnt/cifs cifs username=,password= 0 0

  4. Finally, we can start a new container with the mount point directory mapped to a host directory.

Let us know in the comments if you need further help with accessing CIFS volume in Docker.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

To sum up, our Support Engineers demonstrated how to access  CIFS volume in Docker.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.