… but it is not ignored when defined in the Dockerfile for a given service itself. Since this is a multicontainer application though, and the documentation clearly states that the label should be applied in docker-compose.yml, this seems like either a documentation oversight for Local Mode, or perhaps a bug.
Hello,
I was not able to reproduce this. I am able to use dbus with a multicontainer application on a device in local mode.
Could you please share your code? or snippets from your docker-compose?
Here is what i tried
docker-compose.yml
version: "2"
services:
ntp-check:
environment:
- "DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket"
labels:
io.balena.features.dbus: "1"
build: ntp
Dockerfile.template in ntp
folder
FROM balenalib/%%BALENA_ARCH%%-alpine
RUN install_packages dbus
COPY start.sh ./
CMD ["bash" , "./start.sh"]
start.sh script
#! /bin/bash
echo "Checking if device time is NTP synchronized"
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
--system \
--print-reply \
--reply-timeout=2000 \
--type=method_call \
--dest=org.freedesktop.timedate1 \
/org/freedesktop/timedate1 \
org.freedesktop.DBus.Properties.GetAll \
string:"org.freedesktop.timedate1"
balena-idle
I had the device in local-mode and ran balena push <device ip>
Here is the result:
root@support-check-dbus# npx balena push 192.168.100.14
[Info] Starting build on device 192.168.100.14
[Build] [ntp-check] Step 1/6 : FROM balenalib/armv7hf-alpine
[Build] [ntp-check] ---> e1181b610748
[Build] [ntp-check] Step 2/6 : RUN install_packages dbus
[Build] [ntp-check] ---> Running in 5d5618a8169c
[Build] [ntp-check] Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/):
[Build] Architecture: ARM v7
[Build] OS: Alpine Linux 3.13
[Build] Variant: run variant
[Build] Default variable(s): UDEV=off
[Build] Extra features:
[Build] - Easy way to install packages with `install_packages <package-name>` command
[Build] - Run anywhere with cross-build feature (for ARM only)
[Build] - Keep the container idling with `balena-idle` command
[Build] - Show base image details with `balena-info` command
[Build] [ntp-check] fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/main/armv7/APKINDEX.tar.gz
[Build] [ntp-check] fetch https://dl-cdn.alpinelinux.org/alpine/v3.13/community/armv7/APKINDEX.tar.gz
[Build] [ntp-check] OK: 23 MiB in 62 packages
[Build] [ntp-check] Removing intermediate container 5d5618a8169c
[Build] [ntp-check] ---> cc03a7a3ec67
[Build] [ntp-check] Step 3/6 : COPY start.sh ./
[Build] [ntp-check] ---> 64992f543ffb
[Build] [ntp-check] Step 4/6 : CMD ["bash" , "./start.sh"]
[Build] [ntp-check] ---> Running in 03996500c64b
[Build] [ntp-check] Removing intermediate container 03996500c64b
[Build] [ntp-check] ---> a7a6654f24d1
[Build] [ntp-check] Step 5/6 : LABEL io.resin.local.image=1
[Build] [ntp-check] ---> Running in ea2de0a40073
[Build] [ntp-check] Removing intermediate container ea2de0a40073
[Build] [ntp-check] ---> f7ba9b755753
[Build] [ntp-check] Step 6/6 : LABEL io.resin.local.service=ntp-check
[Build] [ntp-check] ---> Running in d511d541a4f5
[Build] [ntp-check] Removing intermediate container d511d541a4f5
[Build] [ntp-check] ---> efc7b02de798
[Build] [ntp-check] Successfully built efc7b02de798
[Build] [ntp-check] Successfully tagged local_image_ntp-check:latest
[Info] Streaming device logs...
[Live] Watching for file changes...
[Live] Waiting for device state to settle...
[Logs] [7/2/2021, 4:14:11 PM] Creating network 'default'
[Logs] [7/2/2021, 4:14:13 PM] Installing service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:14:13 PM] Installed service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:14:13 PM] Starting service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:14:15 PM] Started service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:14:15 PM] [ntp-check] Checking if device time is NTP synchronized
[Logs] [7/2/2021, 4:14:15 PM] [ntp-check] Checking if device time is NTP synchronized
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] method return time=1625228055.996868 sender=:1.972 -> destination=:1.969 serial=3 reply_serial=2
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] array [
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "Timezone"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant string ""
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "LocalRTC"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant boolean false
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "CanNTP"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant boolean false
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "NTP"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant boolean false
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "NTPSynchronized"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant boolean true
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "TimeUSec"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant uint64 1625228055995416
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] dict entry(
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] string "RTCTimeUSec"
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] variant uint64 0
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] )
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] ]
[Logs] [7/2/2021, 4:14:16 PM] [ntp-check] Idling...
If i comment out the dbus
label in the docker-compose file and push again I get:
[Info] Streaming device logs...
[Live] Watching for file changes...
[Live] Waiting for device state to settle...
[Logs] [7/2/2021, 4:19:40 PM] Killing service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:52 PM] Service exited 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:52 PM] Killed service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:53 PM] Installing service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:53 PM] Installed service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:53 PM] Starting service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:55 PM] Started service 'ntp-check sha256:efc7b02de798d8dd2f52e80b82fd3aaaf9d6a176adcac44806febe001988efde'
[Logs] [7/2/2021, 4:19:55 PM] [ntp-check] Checking if device time is NTP synchronized
[Logs] [7/2/2021, 4:19:55 PM] [ntp-check] Failed to open connection to "system" message bus: Failed to connect to socket /host/run/dbus/system_bus_socket: No such file or directory
[Logs] [7/2/2021, 4:19:55 PM] [ntp-check] Idling...
suggesting the label is being picked up.
grateful if you could share some error message you are seeing so we can better help you.
thanks
Well, this is embarrassing. I don’t know what changed between last Friday and today, but now I can’t even reproduce my own issue. I can access DBUS both via your example and in my project, when defining the io.balena.features.dbus
label in docker-compose.yml
. My docker-compose is a bit more complicated, maybe this was a simple typo or something:
version: '2'
services:
azure_bridge:
# subscribes to an MQTT channel, takes data published to that channel, sends it to IOTHub.
# privileged: true
build: ./
restart: unless-stopped
network_mode: "host"
depends_on:
- mqtt
environment:
- HUB_CONN_STR=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
labels:
io.balena.features.dbus: '1'
mqtt:
image: arm64v8/eclipse-mosquitto
# platform: linux/arm64/v8
restart: unless-stopped
expose:
- "1883"
- "9001"
network_mode: "host"
couchdb_single_node:
image: crspectare.azurecr.io/couchdb-single-node:dev
expose:
- "5984"
restart: unless-stopped
environment:
- COUCHDB_PASSWORD=superuser
- COUCHDB_USER=root
volumes:
- couchdb_data:/opt/couchdb/data
network_mode: "host"
couchdb_manager:
image: crspectare.azurecr.io/couchdb-manager:dev
restart: unless-stopped
depends_on:
- couchdb_single_node
- azure_bridge
network_mode: "host"
sensor_simulator_1:
image: crspectare.azurecr.io/sensor-simulator:dev
restart: unless-stopped
network_mode: "host"
depends_on:
- azure_bridge
volumes:
couchdb_data:
external: false
Dockerfile
# Establish base image
FROM python:3-slim
# COPY ./azure-bridge ./azure-bridge
COPY ./ ./
# WORKDIR /azure-bridge
RUN pip3 install --no-cache-dir -r requirements.txt
RUN apt-get update && apt-get install -y dbus python3-gi python3-gi-cairo gir1.2-gtk-3.0
CMD [ "sh", "-c", "python3 -u main.py" ]
But yeah, I guess this issue is resolved!