One more question, what version of Python are you running? Configuration > info> python version
in docker I’m running the version 3.8.7 in raspbian I’m running the vesion 3.8.6
So I am more familiar with venv, but the issue may be your docker container does not have direct access to the host, and since GPIO are right at kernel level, they need this. Thats why Pi user has root access. I would start here: Docker Access to Raspberry Pi GPIO Pins - Stack Overflow
Thanks to your support I solved the problem, it was related to the permission, for the moment I solved running Docker with the “–privileged” option, for sure exist a more “secure” options and I’ll try to refine the command in order to give to docker just the needed permission for GPIO instead of root permissions.
But just for future user this command works:
docker run --init -d --name="home-assistant" --privileged -e "TZ=Europe/Rome" -v /home/homeassistant/.homeassistant:/config --net=host --restart unless-stopped homeassistant/raspberrypi4-homeassistant:stable
–privileged this option give to docker the priveldged permission, .please, pay attention in giving root privileges