How to get GPIO in /sys/class in Docker image for BeagleBone?

Project:
I am working on a project that will allow me to send messages to other devices remotely. I have access to LEDs connected to pins to be used to confirm whether a message has been sent/error (was not able to send the message)/being transmitted. I managed to do that with Beaglebone board and with LEDs connected to the pins. So, I thought of working virtually with various other beaglebones (same Docker Image but multiple containers) where I would echo to the pins with values and that will trigger certain conditional statements, etc. which will just log to the txt file. Hopefully, that will provide me with an estimated performance of the system before I go ahead and buy other beaglebones.

Question:
I am using Windows Docker Desktop where I used VSCode to created DocekrFile as a trial which uses the following code:

FROM balenalib/beaglebone-black-debian:buster

CMD ["/bin/bash"]

however, when I managed to build the docker image and managed to run it using the following command:

docker run -it --privileged testgpio

I can’t seem to find the gpio in the /sys/class, I am getting the following:

root@4be3b7480d92:/# ls /sys/class
bdi    bsg   devlink  input  ipvtap   mem   nd   pci_bus  power_supply  pps  rtc          scsi_disk     scsi_host  tty  vc    virtio-ports
block  cuse  drm      iommu  macvtap  misc  net  phy      ppp           ptp  scsi_device  scsi_generic  thermal    uio  vfio  vtconsole

How can I get gpio to be in the /sys/class as I would need it in my project?

In addition, I also used the following in the file code but the results was the same.

RUN apt-get update && apt-get install -y \
    libgpiod2 \
    libgpiod-dev \
    && rm -rf /var/lib/apt/lists/*

Section 1:

I used find to look for gpio and I got the following:

find / -name "*gpio*"
find: File system loop detected; ‘/sys/kernel/debug/device_component’ is part of the same file system loop as ‘/sys/kernel/debug’.
/sys/bus/platform/drivers/gpio-clk
/var/lib/dpkg/info/libgpiod2:armhf.symbols
/var/lib/dpkg/info/libgpiod2:armhf.md5sums
/var/lib/dpkg/info/libgpiod-dev.md5sums
/var/lib/dpkg/info/libgpiod2:armhf.shlibs
/var/lib/dpkg/info/libgpiod2:armhf.triggers
/var/lib/dpkg/info/libgpiod-dev.list
/var/lib/dpkg/info/libgpiod2:armhf.list
/usr/include/gpiod.h
/usr/include/gpiod.hpp
/usr/share/doc/libgpiod2
/usr/share/doc/libgpiod-dev
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.a
/usr/lib/arm-linux-gnueabihf/libgpiod.so.2.1.1
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so.1
/usr/lib/arm-linux-gnueabihf/libgpiod.so
/usr/lib/arm-linux-gnueabihf/pkgconfig/libgpiod.pc
/usr/lib/arm-linux-gnueabihf/pkgconfig/libgpiodcxx.pc
/usr/lib/arm-linux-gnueabihf/libgpiod.a
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so.1.0.3
/usr/lib/arm-linux-gnueabihf/libgpiod.so.2

Section 2:

I have modified my DockerFile to the following:

FROM balenalib/beaglebone-black-debian:buster

# Install required packages
RUN apt-get update && \
    apt-get install -y git build-essential autoconf automake libtool pkg-config autoconf-archive

# Clone libgpiod from official repository
RUN git clone https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git && \
    cd libgpiod && \
    ./autogen.sh --enable-tools=yes --prefix=/usr/local && \
    make && \
    make install

# Clean up
RUN apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
    rm -rf libgpiod

RUN apt-get update && apt-get install -y \
    libgpiod2 \
    libgpiod-dev \
    && rm -rf /var/lib/apt/lists/*

CMD ["/bin/bash"]

I got it from following link

Kernel LibGPIO

Managed to get empty results for gpiodetect and gpioinfo:

root@02c40b9d76da:/# find / -name "*gpio*"
/sys/bus/platform/drivers/gpio-clk
/var/lib/dpkg/info/libgpiod2:armhf.symbols
/var/lib/dpkg/info/libgpiod2:armhf.md5sums
/var/lib/dpkg/info/libgpiod-dev.md5sums
/var/lib/dpkg/info/libgpiod2:armhf.shlibs
/var/lib/dpkg/info/libgpiod2:armhf.triggers
/var/lib/dpkg/info/libgpiod-dev.list
/var/lib/dpkg/info/libgpiod2:armhf.list
/usr/include/gpiod.h
/usr/include/gpiod.hpp
/usr/include/linux/gpio.h
/usr/share/doc/libgpiod2
/usr/share/doc/libgpiod-dev
/usr/local/bin/gpioget
/usr/local/bin/gpiodetect
/usr/local/bin/gpionotify
/usr/local/bin/gpioset
/usr/local/bin/gpioinfo
/usr/local/bin/gpiomon
/usr/local/include/gpiod.h
/usr/local/lib/libgpiod.so.3.1.0
/usr/local/lib/libgpiod.so.3
/usr/local/lib/libgpiod.so
/usr/local/lib/pkgconfig/libgpiod.pc
/usr/local/lib/libgpiod.la
/usr/local/lib/libgpiod.a
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.a
/usr/lib/arm-linux-gnueabihf/libgpiod.so.2.1.1
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so.1
/usr/lib/arm-linux-gnueabihf/libgpiod.so
/usr/lib/arm-linux-gnueabihf/pkgconfig/libgpiod.pc
/usr/lib/arm-linux-gnueabihf/pkgconfig/libgpiodcxx.pc
/usr/lib/arm-linux-gnueabihf/libgpiod.a
/usr/lib/arm-linux-gnueabihf/libgpiodcxx.so.1.0.3
/usr/lib/arm-linux-gnueabihf/libgpiod.so.2
root@02c40b9d76da:/# gpiodetect
root@02c40b9d76da:/# gpioinfo
root@02c40b9d76da:/# gpioinfo -c 1

Hey there @WDPad751 welcome to the forums. Could you share what BeagleBone board you’re using (what device type you’ve selected in balenaCloud), along with the balenaOS version? Edit: I see Black mentioned in the Dockerfile, so just the version would help.

Hello @chrisys, Thank you for your reply.

I am using the following image in my Beaglebone BeagleBone Image

Well I didn’t state the version for BeagleBone, won’t that resolve to the latest version?

Ah, I assumed you were using balenaOS. In that case I’m not sure, does /sys/class/gpio work correctly on the device outside of Docker?

If I use windows as a host and Beaglebone, it works fine. I just thought that if I added the balenaOS image it would include the gpio in the/sys/class/gpio but I couldn’t find it there as I wanted to use Docker as virtual testing.