[systemd-devel] networkd must start before nspawn at container

arnaud gaboury arnaud.gaboury at gmail.com
Sat May 2 02:27:06 PDT 2015


My host/conatiner networking are both managed by systemd-netwrokd. I
have a bridge Br0 on host and vb-MyContainer for the conatiner. Both
have a fix local IP.

I boot container at host boot  this way:

------------------------------------------
$ cat /etc/systemd/system/systemd-nspawn at .service
.................
ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot
--link-journal=try-guest --network-bridge=br0 --machine=
------------------------------------------

Unfortunately, systemd-nspawn at poppy fails sometimes at boot :

----------------------------------------------------------------------------
$ systemctl status systemd-nspawn at poppysystemd-nspawn at poppy.service - Container poppy
   Loaded: loaded (/etc/systemd/system/systemd-nspawn at .service;
enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2015-05-01 19:34:56
CEST; 50s ago
     Docs: man:systemd-nspawn(1)
  Process: 544 ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit
--boot --link-journal=try-guest --net

 work-bridge=br0 --machine=%I (code=exited, status=1/FAILURE)
 Main PID: 544 (code=exited, status=1/FAILURE)

May 01 19:34:55 hortensia systemd[1]: Starting Container poppy...
May 01 19:34:55 hortensia systemd-nspawn[544]: Failed to resolve
interface br0: No such device
May 01 19:34:56 hortensia systemd[1]: systemd-nspawn at poppy.service:
main process exited, code=exite...LURE
May 01 19:34:56 hortensia systemd[1]: Failed to start Container poppy.
May 01 19:34:56 hortensia systemd[1]: Unit
systemd-nspawn at poppy.service entered failed state.
May 01 19:34:56 hortensia systemd[1]: systemd-nspawn at poppy.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
--------------------------------------------------------------------------

Obviously the reason is networkd has not been activated. I solved this
issue this way:

$  cat /etc/systemd/system/network.target
--------------------------------------------------
[Unit]
Description=Network
Documentation=man:systemd.special(7)
Documentation=http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
After=network-pre.target
RefuseManualStart=yes

[Install]
WantedBy=machines.target
----------------------------------------------
# systemctl enable machines.target

I added machines.target in Before section options in systemd-netwrokd.service
$ cat /etc/systemd/system/systemd-netwrokd.service
--------------------------------------
.............
Before=network.target multi-user.target shutdown.target machines.target
..................
-----------------------------------------

My issue is now solved. I just wonder if my setting is a good practice.

Thank you for advice




google.com/+arnaudgabourygabx


More information about the systemd-devel mailing list