4

I've been working with systemd-nspawn and have a couple of containers that I'd like to automatically start at system start.

I'm using arch linux and according to the archwiki entry, the following code should do the trick

# systemctl enable [email protected]
# systemctl start [email protected]

Assuming the container MyContainer is in /var/lib/machines and was created with something like:

# pacstrap -i -c -d /var/lib/machines/MyContainer base

I can start the container with:

# sudo systemd-nspawn -b -D /var/lib/machines/MyContainer

and

# systemctl start [email protected]

as well as

# machinectl start MyContainer

but I just can't get the container to start at boot and running sudo systemctl status [email protected] right after boot doesn't show any errors. Does anyone know what I need to do? Does there maybe need to be another service running?

1 Answer 1

3

After doing a little more research, I discovered the problem. It's not that another service needs to be running, but instead another target, specifically machines.target, so running

systemctl enable machines.target

in addition to the commands above made it so that MyContainer starts at boot.

As a side note, this wasn't immediately clear because when I call

systemctl list-units --all --type=target

on both of my computers (both running arch linux), machines.target is not included in the list. Not sure why, but that was the fix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .