I’d like to know how can I access a couple of unix sockets from inside a container.
I have a process which creates two unix sockets on /tmp on the balenaOS and I want to make them accesible to a container.
BalenaOS is a lightweight hypervisor OS which tries hard to isolate the hostOS from the containers apps. There are standard interfaces for applications to access a selected set of hostOS functionality (dbus and feature labels), and bind mounts is not one of them.
If you explain your use case with details we will very likely be able to suggest what the right approach is.
I’ve got a couple of unix sockets created on /tmp by a process needed by our owa5X. This sockets are the gateway for a power manager process to communicate with a little uC that handles power features on the HW.
Besides, some others non-mandatory processes of ours also need those sockets and I’m trying to use them from a balena container.
I’ve got a couple of unix sockets created on /tmp by a process needed by our owa5X
The first thing that comes to mind would be modifying the process to expose a local socket instead that could be accessed from a container running in the host network. Or using socat or similar to proxy the unit socket to a network socket.
If that does not work, as you are the maintainers of that device type, you could PR the bind mounting of that specific unix socket into containers.
I’m just simply unable to run a container in local mode as Privileged
I think PR those bind mounting would be the best option for us. Is there any reference of that kind of PR to be able to look at?
Actually that’s not going to be an option. You could PR a hostOS bind mount, but you actually need an application bind mount which the supervisor would need to provide.
So, if modifying the service to use local/network sockets is not an option, the only other bad technical solution which would introduce security concerns would be to use the engine socket to access the unix socket on the host, or to directly mount the physical device where the unix socket is located from a container with enough privileges to do so.
I’m just simply unable to run a container in local mode as Privileged
That’s not something I can reproduce. If I push a multicontainer application with a privileged service in local mode, the service remains privileged.
Could you maybe provide reproduction steps with a simple app like the one in the getting started?
We are still in the dark with this issue. Could you elaborate on using the engine socket to access the unix socket on the host?
Any example, reference or use case that I can take a look at?
Do you mean using socket labels in the docker-compose file?
Yes, using the socket label you can expose the engine socket to a privileged container in the application and use it to have root access to the hostOS.
An example service that runs commands on the hostOS can be:
Be aware that root access to the hostOS is a security hazard. My advice would be to use it as a one time container to perform some initial configuration so that it is not running all the time.
As I mentioned before, the correct approach would be to modify the service to use local/network sockets, and this solution should only be used if that is not possible.