Systemd not available within container despite INITSYSTEM on

HI All,

I have trawled the internet and these forums but am unfortunately still stuck with a problem concerning systemd inside of a container running on balenaOS.

My environment:
HOST OS: balenaOS 2.31.5+rev1
Supervisor: 9.11.3
Raspberry Pi3.

The opening lines of my Dockerfile…

FROM balenalib/%%RESIN_MACHINE_NAME%%-debian:jessie
ENV INITSYSTEM on

My docker-compose.yml file for this single container.

version: '2.1'
networks: {}
volumes:
  resin-data: {}
services:
  main:
    build:
      context: .
    **privileged: true**
    tty: true
    **restart: always**
    network_mode: host
    volumes:
      - 'resin-data:/data'
    labels:
      io.resin.features.kernel-modules: '1'
      io.resin.features.firmware: '1'
      io.resin.features.dbus: '1'
      io.resin.features.supervisor-api: '1'
      io.resin.features.resin-api: '1'

When trying to run any service related type commands using systemd I get the following error:

Failed to get D-Bus connection: Unknown error -1

I have specified ENV INITSYSTEM on in my Dockerfile.
I have added the Device Service Variable INITSYSTEM on through the dashboard as well but I cannot get systemd to run?

Any advice or ideas from anyone out there??

systemctl status too returns that error above.

Thanks
Jonathan

Hi @JonathanDavis, as mentioned in the docs, the balenalib base images don’t come with systemd installed, that often causes problems from our experience/support cases. If you want to re-add systemd for yourself, you can see our documentation at https://www.balena.io/docs/reference/base-images/base-images/#major-changes and the section after that https://www.balena.io/docs/reference/base-images/base-images/#installing-your-own-initsystem There are links to examples how to add the required modifications to the base image to have systemd there again, but as of now, our official images won’t have that (and thus INITSYSTEM won’t do anything). Let us know if you have any other questions.

Oh my. Why did I not reach out sooner! :roll_eyes:

I will look through that documentation right now.

Thank you for your quick reply!

Jonathan

1 Like

Sure thing! In our experience almost everything can be done without systemd in the container and setting different parts of the application up nicely in their own containers/services to decouple them from each other. Depending on what you are doing (ie. what’s your application), that might worth looking at as well!

Morning! Yes I would like to embrace the improvements that can be found by decoupling everything and running each application/“service” in its own container. I will create a new topic in the forum asking for any advice as to best practise so as to accomplish this!

Thanks for your time imrehg