Using systemctl in toolbox

I created a toolbox for my neomutt/mstmpd etc for mail reading. Normally, if this was a regular desktop (or server) setup, I would have a systemd timer so that my mail would be synced with my mail server. Under toolbox, I am not able to enable and start my mbsync.timer.

I have tried to do the following:

kcc@toolbox: sudo systemctl daemon-reload
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down

and the same is true with trying to do a timer:

kcc@toolbox: sudo systemctl --user enable mbsync.timer
Failed to enable unit, unit mbsync.timer does not exist.
So that would mean that systemctl doesn’t even see my ~/.config/systemctl/user directory.

So is there any way to make my timers work within the toolbox?

1 Like

Hey KC, I have not set up a systemd timer for my toolbox, but I had some ideas.

The directory for user units should be ~/.config/systemd/user (not systemctl).

But even with the correct directory, systemd doesn’t run inside of toolbox [1]. I’ve run into not having systemd a few times but there’s usually a workaround. Have you considered using your host systemd to run the daemon inside your container? Might be as easy as adding “toolbox run” to the beginning of your ExecStart.

[1] Why don't toolbox containers include sytemd?

You are correct, that was a typo on my part earlier. I am not that savvy in container usability. Things like my e-mail client or other services were a part of my native OS and containers (lxc, docker, etc.) was something that was lightweight and more or less temporary. Now I am dealing with a more or less lightweight OS that is streamlined and everything else is containerized. Interesting concept!

So could you elaborate on how to use ExecStart to start my tooxbox? For instance, when I log in to my machine, the first thing that I do is spin up my “Mutt” toolbox. Once I enter the mutt toolbox, I fire up tmux and start my mutt client and a couple of ssh sessions. I need the mbsync.timer to sync up my email within the mutt toolbox, so how do I get that working?

I found a user service unit (that I’m not using, so YMMV). For example, ~/.config/systemd/user/rslsync.service:

Description=Resilio Sync

ExecStart=rslsync --nodaemon


My suggestion was to change the ExecStart line to:

ExecStart=toolbox run rslsync --nodaemon

I haven’t tried this, so I’m not sure it works!

The idea is that systemd is normally running on your host. And toolbox uses the same container by default (should be fedora-toolbox-33). So you should be able to use the host systemd to run mbsync inside of the toolbox container.

Hope that helps! I’d encourage you to also play around with toolbox and podman to figure them out. I think it really helps when it comes to customizing things like this.

This is somewhat confusing… In your example above, it would seem that you creates a service and a possibly a time, and then in the ExecStart you execute the rslsync.

In my case I have a toolbox called mutt, which I have mbsync installed. Are you saying that I need to install mbsync as the OS layer along with msmtsp, enable the timer and then open the toolbox mutt?

toolbox run will run the command inside of the toolbox container, not on the host. So it should be sufficient to install mbsync inside the container without layering it with rpm-ostree. I think this is confusing because the idea is to use systemd on the host to run mbsync inside the toolbox. I think you are assuming that everything needs to run on the host, or everything needs to run inside the toolbox, which is not what I’m suggesting.

I’ll also mention again that this is totally untested, I’m just trying to give some ideas that may point you in a helpful direction. I hope it is useful but I have no guarantees!

I made the changes that you suggested, but still no go. This is almost a deal breaker for me, since I am used to be having my email waiting for as opposed to manually have to sync up the mail. As a fall back I would just use cron and call it a day, but cronie is run as a systemd service, which does really help me.

Perhaps this post by Dan Walsh would be of help to you. Hope this helps, good luck
Also this at the official Podman doc site

I think a more containerized way of handling mutt/msmtpd is to create a container containing mutt and msmtpd that you run from your host terminal. I.e. don’t use toolbox for this.

You then have a separate container running mbsync. The only communication needed between mbsync and mutt is your mailbox, which will be shared via a mounted volume.

These containers are run using podman, and you use the host systemctl to set up a timer which triggers the mbsync container.

I was actually thinking along those lines using the fedora minimal container image. I figured you could run them from the same pod to share resources. Currently my mutt container is partially working for me.