[systemd-devel] Waiting for nspawn services

Rich Freeman r-systemd at thefreemanclan.net
Sat Oct 25 02:39:51 PDT 2014


One of the useful options in nspawn is the ability to boot the init
within the container using -b, especially if that init happens to be
systemd.

However, I could not find any easy way to set a dependency on a
service within a container.

Example use case:
Unit 1 boots an nspawn container that runs mysql
Unit 2 launches a service that depends on mysql, or it might even be
another container that depends on mysql.

I could put together a script that pings mysql until it is up, but the
original mysql unit already has to make the determination as to
whether the service is ready, so this is redundant.  Also, that is a
solution specific to a single daemon, while the problem is generic.

I could think of a few possible ways to solve this.

1.  Have a way to actually specify a dependency on a unit within a container.
2.  Have a generic wait program that can wait for any unit to start
within a container, or perhaps even on a remote host.
3.  Have a way for nspawn to delay becoming online until all services
inside have become online.

Actually, being able to express unit dependencies across machines
might be useful on many levels, but I'll be happy enough just to be
able to handle containers on a single host for now.

--
Rich


More information about the systemd-devel mailing list