Docker Image is missing GPIO in /sys/class

I am using the Balena Images for getting the base image for Beaglebone. I thought that when getting the image of the beaglebone it would include the gpio in the /sys/class, however, it is missing.

I wanted to have a virtual containerised beaglebone to use in my project as I needed to test how the beaglebone would react and estimate the performance when more than 2 beaglebones are communicating where it manipulates pins virtually to simulate if a message was received, sent, or (if there has been error/problem).

Is there a way to have like virtual GPIOs in a docker image?

/sys/class is not a regular folder. That is a filesystem for communicating with the kernel. The container does not have its own kernel as it is just an isolated process or processes running on the host and not a virtual machine.

I never used gpio, but you are probably looking for something like this:

@rimelek Thank you for the reply, I will take a look at the link.

Just a question with regards to the kernel, do all the containers not have a kernel? What if the container does not have a kernel does it require like Kernel Git to be added and compiled into the container to be able to have some sys functions, for instance, gpio?

What about other images like Balena Images

I assume this won’t work for Windows host OS as I am using Docker Desktop in Windows OS?

This is the important part from my previous post:

I emphesized “running on the host”. There is no kernel in the container but there is a kernel on the host. The container can’t see it, because it does not need to. It sends system calls if it has permission and the kernel with get it. You can run this for example:

docker run --rm -it bash uname -a

You will get the kernel version, but you will see nothing in /boot on the filesystem. It will probably not even exist. Doesn’t matter what image you use. A container is a process on the host as any other. It just can’t see everything. Check my tutorial and video about namespaces: Docker network and network namespaces in practice — Learn Docker documentation

That’s correct. I missed that part.