Mounting a shareFolder inside a container

Hi,

I have a Avalonia app running on TorizonCore thanks to one of the ApolloX templates.
Inside the app I need to be able to specify a Windows shareFolder and mount it inside the container.

So far I was partly successful, I was able to add cifs-utils and the SYS_ADMIN permission so from outside the container I can “docker exec mount …” and it works.
However inside I’m not able to make it run with sudo. I get an error
“sudo: unable to resolve host verdin-imx8mp-1414147: Name or service not known\n”
I found a fix that would need to edit /etc/hosts inside the docker file but that crashes with a filesystem is read-only error.

There is also the issue itself of having the container have access to mount, which is like it having sudo. Would it be possible perhaps to start a separate container from inside my app that would mount to the shareFolder and then I would connect to that container?

Any advice is welcome, thanks

Hi @jakub.bm4n ,

Welcome to our community!

I’m not sure I understood your issue: inside your application container you want to access a network-shared directory on a Windows machine. Is this correct?

You can probably configure TorizonCore directly (i.e. outside the container) to access and mount the shared directory, in a similar way you would do in a desktop Linux machine. Once that’s done, you can then bind mount the directory when starting your container.

Best regards,
Lucas Akira

Hi Lucas,

inside your application container you want to access a network-shared directory on a Windows machine

Yes that is correct. But the directory is not known when the container starts and is inputted later by the user into the application.

So I think it has to be done a different way.

Hi @jakub.bm4n ,

I managed to mount the shared Windows folder and access it from inside a container. In this container I also configured a password for user torizon, as this isn’t setup by default in our container images.

Here’s the Dockerfile I’ve used to create the image:

Dockerfile.smb
FROM torizon/arm64v8-debian-base:3-bookworm

RUN apt-get update

RUN apt-get install -y cifs-utils

RUN echo 'torizon:new_password_here' | chpasswd

RUN usermod -a -G sudo torizon

USER torizon

WORKDIR /home/torizon

RUN mkdir mount_smb

CMD ["/bin/bash"]

# In your SoM (Verdin iMX8M Plus in this case), build docker image with:
# docker build -f Dockerfile.smb -t smb_share:arm64 .

# Run container with
# docker run -it --cap-add=DAC_READ_SEARCH --cap-add=SYS_ADMIN --network=host smb_share:arm64 bash

# Once inside the container, mount the shared folder:
# sudo mount.cifs //<PC-name or IP>/<shared_windows_folder> /home/torizon/mount_smb -o user=<Win user>

With the Dockerfile above you can build a Docker image directly on TorizonCore.


Once the shared folder is mounted, user torizon has read and execute permissions inside it. Only root has write permissions, so you need to use sudo if you plan to write files as torizon.

Let me know if this helps you.

Best regards,
Lucas Akira

Hi Lucas,

I’ve run into a some issues on the way. I’m unable to run the sudo command inside the container getting a error

sudo: unable to resolve host verdin-imx8mp-1414147: Name or service not known

Once that works and I mount the shared folder how would I access it from the main container?

Thank you

Hi @jakub.bm4n ,

Which container are you trying to use? Is it based on one of our Debian images?

Does this error occur on the Dockerfile I shared? How are you starting your container?

Once that works and I mount the shared folder how would I access it from the main container?

The idea here is to mount the shared folder on the same container that has the application, but I think you can access the same directory on different containers using bind mounts or Docker volumes.

Best regards,
Lucas Akira

Hi Lucas,

I got it to work if I switch running the smb container as root. I was also able to connect the main container to the smb one via the volumes.

The sudo doesn’t work on both the main container and also the smb container.
For the main container I use the community Avalonia framebuffer template
For the smb container I use the one you sent me

Thank you

Glad you managed to solve your issue!

Best regards,
Lucas Akira