Run systemctl command at boot

Hi all,
I’m trying to setup a container with systemctrl running on. basically I just need to run this command:

systemctl status NetworkManager.service

I need to run this command in order to be able to put the device in monitor mode, and thanks to this post I’ve found this solution (that actually works if I type the command by ssh into the device). Moreover, I’m following this post: installing-your-own-initsystem to make this thing work.
To be precise, I’m using the example in this repo

What I’m facing is basically that this command that is in

exec env DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket /sbin/init quiet systemd.show_status=0

hangs and cannot execute the rest of my commands (which are just right next). Dunno if this is the right behavior of init…
Do you have some clue?
How can I basically run just the command above? It would be great if there is a sort of “scripts” that could be run at startup by the host… are there any particular solution to achieve that?


Hey @MarcoAbi

To mess with the network manager service in a container you need to make sure you that you have a few things in the right docker files:
In your docker-compose.yml:
io.resin.features.dbus: '1'

In your Dockerfile.template:
RUN apt-get update && apt-get install -y \
network-manager=1.14.* \
systemctl mask NetworkManager.service

Then I have:
ENV DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket

I don’t know why you need your own initsystem for monitoring mode?

I unmanaged the device from the network manager cli then put it in monitoring mode. See my post here for my struggles with this. Or skip to the good parts here.

In general, anything that you can do on the host, you should be able to do in a privileged container with the right setup. It was hard for me to come around to that mindset.

Good luck and let me know if you have further questions. I have a bit of experience with monitor mode. In exchange, I would love to hear what adapter you’re using and what your performance is like if your willing to share!