On Sat, May 2, 2015 at 11:27 AM, arnaud gaboury <arnaud.gabo...@gmail.com> wrote: > > 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@.service > ................. > ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot > --link-journal=try-guest --network-bridge=br0 --machine= > ------------------------------------------ > > Unfortunately, systemd-nspawn@poppy fails sometimes at boot : > > ---------------------------------------------------------------------------- > $ systemctl status systemd-nspawn@poppy > ● systemd-nspawn@poppy.service - Container poppy > Loaded: loaded (/etc/systemd/system/systemd-nspawn@.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@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@poppy.service entered failed state. > May 01 19:34:56 hortensia systemd[1]: systemd-nspawn@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.
My issue is not solved at all and systemd-nspawn will not start at host boot because Br0 interface is not found. I am trying to figure out how to ensure netwrokd will be started before systemd-nspawn with playing with target units and before and after options, but can't find a solution. I crated /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 Before=machines.target RefuseManualStart=yes [Install] WantedBy=multi-user.target ---------------------------------------------------------------- I crated /etc/systemd/system/machines.target ---------------------------------------------------- [Unit] Description=Containers Documentation=man:systemd.special(7) Requires=basic.target Conflicts=rescue.service rescue.target After=basic.target rescue.service rescue.target Before=network.target [Install] WantedBy=multi-user.target ----------------------------------------------------------- modified systemd-networkd: ----------------------------------------------------- [Unit] Description=Network Service Documentation=man:systemd-networkd.service(8) ConditionCapability=CAP_NET_ADMIN DefaultDependencies=no # dbus.service can be dropped once on kdbus, and systemd-udevd.service can be # dropped once tuntap is moved to netlink After=systemd-udevd.service dbus.service network-pre.target systemd-sysusers.service Before=network.target multi-user.target shutdown.target machines.target Conflicts=shutdown.target Wants=network.target ------------------------------------------------------ modified systemd-nspawn@service ----------------------------------------------------- [Unit] Description=Container %I Documentation=man:systemd-nspawn(1) PartOf=machines.target Before=machines.target network.target [Service] ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --network-bridge=br0 --machine=%I KillMode=mixed Type=notify RestartForceExitStatus=133 SuccessExitStatus=133 Delegate=yes [Install] WantedBy=machines.target ---------------------------------------------------- $ tree /etc/systemd/system .................... ├── machines.target.wants │ └── systemd-nspawn@poppy.service -> /etc/systemd/system/systemd-nspawn@.service ................................... ├── multi-user.target.wants │ ├── acpid.service -> /usr/lib/systemd/system/acpid.service │ ├── adb.service -> /usr/lib/systemd/system/adb.service │ ├── dkms.service -> /usr/lib/systemd/system/dkms.service │ ├── fstrim.timer -> /usr/lib/systemd/system/fstrim.timer │ ├── haveged.service -> /usr/lib/systemd/system/haveged.service │ ├── iptables.service -> /usr/lib/systemd/system/iptables.service │ ├── machines.target -> /etc/systemd/system/machines.target │ ├── mysqld.service -> /usr/lib/systemd/system/mysqld.service │ ├── network.target -> /etc/systemd/system/network.target │ ├── psd.service -> /etc/systemd/system/psd.service │ └── remote-fs.target -> /usr/lib/systemd/system/remote-fs.target ............................................................... ├── network.target.wants │ └── systemd-networkd.service -> /etc/systemd/system/systemd-networkd.service > > Thank you for advice > > _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel