Mounting external drive (USB) persistent storage to be accessed by two different containers.

Hi!

I am trying to mount an external drive USB to be accesses by two different containers.

What is the best way to accomplish this?

My idea was to mount the drive on the Host OS so I can create a Docker Volume to be accessed by both containers but I think that this is not recommended, since I can’t create mounting points on the Host OS (e.g. /mnt is read-only).

Thank you!
Adrià.

1 Like

To clarify the final goal is the following:

Container 1:

  • will mount the drive on /mnt/HDD (with rw permissions)

Container 2:

  • will mount the drive on /mnt/HDD/specific_folder (with rw permissions)

For this reason, I need to expose the contents of the /mnt/HDD to both containers. How can I achieve this?

1 Like

Hello, the documentation for mounting external drives is located here: Communicate outside the container - Balena Documentation but unfortunately, it’s currently not possible to share a mounted device across multiple containers.

1 Like

Hello, some users were able to share an external device across multiple containers by having a container mount the drive then share it with other containers using NFS or Samba. You can find an example here: How to add persistent storage for Balena OS on Raspberry PI? - #26 by janvda

The discussion is a few years old but the approach is still relevant.

1 Like

Hello,

Thank you for the responses!

I’ll try to follow the guide from cmfcruz as soon as I can if this fit my needs!