Hi, can I use variables in device section of docker-compose file? Like this one:
zigbee2mqtt:
build: ./ZIGBEE2MQTT
restart: always
volumes:
- z2m-data:/app/data
devices:
- ${DEVICE}
ports:
- 8008:8008
environment:
- DATA=/app/data
${DEVICE} predefined in balenaCloud as /dev/ttyUSB0:/dev/ttyACM0
Variables are not able to be used in Docker Compose, only in your Dockerfile @AndreyN … What are you building there?
Thanks! It is yet another implementation of smarthome with openhab, zigbee2mqtt and mqtt onboard. I’m searching for simple way to attach various USB-sticks inside zigbee2mqtt container because it doesn’t start if you choose none or wrong one.
Neat! @iayanpahwa do you have any experience with this, by chance?
@dtischler , I’ve used ENV variables inside Dockerfile but not docker-compose. ex- in this project
Hey @AndreyN @dtischler @iayanpahwa
Actually you can add environment directives to the docker-compose, and they will create an environment variable inside your container. However, the balena API isn’t told about this variable (unlike when you use the balenaCloud dashboard) so it won’t show up in the UI.
Here’s an example:
Bucknalla/name-block: Tired of boring balena device names? Why not let us choose! (github.com)
Brilliant, thanks for the info @phil-d-wilson !