Hello again,
I tried this on my device and succeed to reproduce your problem.
It turns out that you probably should install udev
and start the service on your container.
I could do it with your example C code and following Dockerfile
FROM debian:bullseye
RUN apt-get update &&\
apt-get install -y build-essential libudev-dev udev
WORKDIR /test
COPY code.c .
RUN gcc -o code code.c -ludev
CMD service udev restart && ./code
Let me know if it solves your issue.