Systemd and DHCPd

Hello everyone,

I’m trying to tinker with isc-dhcp-server’s package. I tried installing and following the systemd example, but installation fails at the isc-dhcp-server service activation with the error:
[Build] [dhcpd] System has not been booted with systemd as init system (PID 1). Can’t operate.
[Build] Failed to connect to bus: Host is down

FROM balenalib/%%BALENA_MACHINE_NAME%%-node
ENV container docker
RUN install_packages dbus systemd
RUN systemctl mask \
    dev-hugepages.mount \
    sys-fs-fuse-connections.mount \
    sys-kernel-config.mount \
    display-manager.service \
    getty@.service \
    systemd-logind.service \
    systemd-remount-fs.service \
    getty.target \
    graphical.target \
    kmod-static-nodes.service
COPY systemd/entry.sh /usr/bin/entry.sh
STOPSIGNAL 37
ENTRYPOINT ["/usr/bin/entry.sh"]
ENV INITSYSTEM on
RUN install_packages isc-dhcp-server 
COPY ./configs/dhcpd.conf /etc/dhcp/
COPY . .
RUN systemctl start isc-dhcp-server.service
RUN systemctl enable isc-dhcp-server.service
RUN npm i
RUN npm i -g typescript
RUN tsc
CMD ["node", "dist/main.js"]

I tried following the services masterclass, but can no longer find the mentioned systemd folder in the repository. Also tried looking at the examples, but nothing seems to work. Can you help me?

Hello there @matfire, I believe you have not set the dbus env var to point to the hostOS bus.

You’ll need to add DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket either to your Dockerfile as an ENV or to your docker-compose.yml as an environment variable if you have one. For multicontainer projects you’ll also need to need to apply the io.balena.features.dbus label.

You can read more about this here: Communicate outside the container - Balena Documentation

Let me know if this helps!