I launched nodered by means of docker compose up. I connected an air quality sensor to the Raspberry. I installed the i2c packge on Nodered and I connected a timestamp module to the i2c scan node with a debug one at the end. When I click on the timestamp button I find empty into the debug menu. I already checked with the command i2cdetect and these are the results for the i2c channel one.
The command you use to start node red in a docker image has to change. If you're using a docker compose file to start node red, then you'll have to make the change there.
It's all about giving docker access to the device and that has to be done using docker.
It's hard to say what exactly has to change since I don't know anything about your setup and how you started node red inside docker.
To reinforce what Colin has already said. Docker adds a significant layer of complexity. Those 3 services are easily directly installed and managed without the need for Docker.
If you are going to use Docker, you will need to do some learning or how to use it. You are already using docker-compose I think which is probably be best approach for a small-ish docker installation. But you do need to learn about the restrictions it brings and how to get around them.
Hello, I have tried to modify the yaml file according to my last message but when I try to launch all the containers with the compose up I receive an error from the nodered container: error gathering device information while adding custom device "/dev/ttyS0": no such file or directory.
Those a SERIAL PORTS. I'm assuming that, since your sensor is an I2C device, it is either connected direct to the Pi's GPIO. Therefore not serial.
Personally, I have no idea how to allow a Pi's GPIO to be accessed by Docker as I never use a Pi's GPIO, I always use either an Arduino (connected via USB-Serial) or an ESP (connected via Wi-Fi).
Thanks for the answer. I set .yaml file as suggested by gregorius and now I managed to communicate with the sensor, there are still some problems of data unstability (data changes greatly and quickly) but I think that this problem is not linked to node red or docker. Anyway I am using docker compose because with one command I launch all my containers with all applications, it is more suitable, then the enviroment is divided in single containers and that could be safer, just this..
Another problem is that when I turn off the raspberry and turn on again, the permission for the i2c are not more granted even if I modified the yaml file and the communication is not more granted.. strange
The only thing that I changed was to supply the sensor with 3.3 V instead of 5V... Now I put again 5 V and now I can't communicate with the sensor again... wow