Samba/CIFS/NFS share for multicontainers

I searched through the forum but didn’t found anything really matching.

I want to connect to a samba share to retrieve and write data not to the SD card of the raspberry pi.
I can create a container connecting to the samba share, for this a couple of entries in the forum are available. Most other entries are assuming that balena is the smb host, but in our case I’m the smb client.

The problem is that I have a multicontainer setup.
So it would mean that I have to implement the samba connection into each single container resulting in 10 smb connections from each device to the samba host.

I tried to share the connected smb share via named volumes, but the problem is that smb is mounted over the volume.

         - my-data:/mnt
         - my-data:/mnt

The smbclient then mounts /mnt/smbshare. Inside the smbclient container all seems good, but in all othercontainers /mnt/smbshare is empty, as the mount is not propagated.
This seems to be intended behaivor for named volumes for docker and in docker the “workaround” would be using bind-mounts which are not available.

Plugins in balenaEngine are also disabled so using netshare volume docker plugin as alternative is not an option.

As the balena host OS is read-only I’m also unaware how to install cifs-tools there, to mount it on the host side inside the volumes directory and hoping that this is maybe propagated to the containers.

So I’m currently out of ideas how I could achieve this, without having to add the samba functionallity to all needed containers, also meaning that I couldn’t use any default image from dockerhub anymore as I would need to add samba to each of them.

edit: I just found on

Note that currently it’s not possible to share a mounted device across multiple containers. This is a feature that we are currently working on. This documentation will be updated once we add support for this feature.

Do I assume correctly, what I try to achieve its not possible?

Hi Karl, you are right in that sharing a volume/mounted device across multiple containers is not supported. The usual pattern to share data across containers is to have a single container accessing the mounted device and storing the data in a database that is then available via sockets to the other containers.

Thanks for the quick reply.

If I understand you correctly, this means creating a copy of the data on the SD card? Resulting in writes on the SD card and exceeding the disk space of the SD card.

Or do you have a special DB in mind where I could avoid this? Otherwise I also could do a rsync on the named volume and save the DB, but this leads again to the issue with disk space and writes.

edit: Is there a timeline available for this feature?

Hi, I don’t know enough about the specific application to speak in absolute terms, but it sounds like the data could be hosted on an external database and then accessed via the network by all containers instead of having to share the data using samba mounts.
But if you’d rather store the data on the device, I personally like the database for embedded devices as it allows a lot of flexibility on the way data persists. It can even just run from memory with no persistance if required.

Thanks for the reply.
Sadly the ideas here are not suitable for us, as we can’t change the data to be provided from an external database.
Also we are creating in the process PDF files, this creation is writing files on purpose.

For a start we created now a container which is creating the smb share and then using unison to sync the content to a named volume shared between all containers, till we figure out a better solution or sharing a mount between multiple containers is supported by balena.