I have a Python3 app on Raspberry Pi 3 (arm32v7). The app takes a picture at regular time intervals with picamera, detects motion using image analysis with Pillow, detects objects using deep-learning with Tensorflow and sends an annotated image with base64-encoding as JSON payload to an MQTT broker for further processing and display in a gallery with Node-RED.
I have containerized the app using Docker to install on a fleet of old Pi's. I am able to build an image containing the necessary Python packages and then create a container with docker run
command to launch the app. This works as expected, however the command is a very long line of text. To streamline, I created a docker-compose YML. I am able to create a container and launch the app but it fails to run properly.
Here is the docker run command, with env. variables, shared volume and shared device:
docker run --name nonamenow --rm --env USERID=admin --env PASSWD='wrongp@$$wordtryagain' --env MQTTIP='192.168.1.219' --env DELTA=60 --privileged=true -v /opt/vc:/opt/vc --env LD_LIBRARY_PATH=/opt/vc/lib --device /dev/vchiq -it sentry2:envenabled
Creating a container in this way works fine and images start flowing into the gallery. Now, here is the docker-compose YAML I used with docker-compose up
.
version: '3.6'
services:
app:
build: .
container_name: sentrycam21
image: sentry2:envenabled
restart: always
privileged: true
environment:
- LD_LIBRARY_PATH=/opt/vc/lib
- USERID=admin
- PASSWD='wrongp@$$wordtryagain'
- MQTTIP='192.168.1.219'
- DELTA=90
- TOPIC=Surveillance/MainDoor
volumes:
- /opt/vc:/opt/vc
devices:
- "/dev/vchiq:/dev/vchiq"
This fails at runtime, when the program attempts to connect to the MQTT broker. Note that the connection is established correctly by the other method with the same parameters. I tried removing the quotes around the IP address but then it just hangs and nothing further happens.
Please let me know if you see any obvious errors in my docker-compose YAML. Grateful for your help.
- MQTTIP='192.168.1.219'
is not equal to
- "MQTTIP=192.168.1.219"
the later is the one you want i guess.
- "PASSWD=wrongp@$$$$wordtryagain"
ps : you can try to print env like this in python to validate point (1):
import os
print(os.environ)