Hi,
Whenever I issue a “sudo” command in the shell of my docker service running on a raspberry PI 3 (balenaOS 2.29.2+rev1) I get the following message:
sudo: unable to resolve host f0bc010
.
Note that besides the above message the sudo seems to work fine.
Here below a complete example:
node-red@f0bc010:~$ sudo hcitool con
sudo: unable to resolve host f0bc010
Connections:
node-red@f0bc010:~$
So it seems that my service is not able to resolve its own hostname.
Note that my service nodered
is configured in docker-compose.yml (see below) with network_mode : host
.
So what should I do so that my docker service is able to resolve its own hostname when network_mode
is set to host ?
FYI my build files are published in my github repository balena-node-red-eq3. I have copied the respective files from this repository here below.
my docker-compose.yml:
volumes:
node-red-eq3-data: {}
services:
nodered:
build: node-red-eq3
privileged: true
restart: always
network_mode: host
ports:
- "1880:1880"
volumes:
- 'node-red-eq3-data:/data'
labels:
# io.balena.features.kernel-modules: '1'
# io.balena.features.firmware: '1'
# io.balena.features.dbus: '1'
# io.balena.features.supervisor-api: '1'
io.balena.features.balena-api: '1'
# io.balena.update.strategy: download-then-kill
# io.balena.update.handover-timeout: ''
mqtt:
image: panuwitp/mosquitto-arm
ports:
- "1883:1883"
nginx:
build : nginx
network_mode: host
depends_on:
- nodered
ports:
- "80:80"
- "443:443"
restart: always
and my nodered
service dockerfile:
# installing an editor
USER root
RUN apt-get update && apt-get install nano bluetooth bluez libbluetooth-dev libudev-dev
# following command should assure that user node-red can use sudo without requiring to enter a password.
RUN echo "node-red ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# following command is needed to run node js with root priviliges
# see https://github.com/noble/noble#running-without-rootsudo
RUN sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
USER node-red
RUN npm install node-red-contrib-resinio
RUN npm install node-red-dashboard
RUN npm install node-red-contrib-credentials
RUN npm install btsimonh/node-red-contrib-eq3-bluetooth#btsimonh --save
# Take care that the following command is only effective the very first time the application is deployed
# on the device. Next deployments won't overwrite these files as /data is mounted volumne.
COPY settings.js flows.json flows_cred.json package.json /data/