Just recently I had similar requirement of making sure NFS is up before
starting an LXC container. After some unsuccessful experiments with
lxc.hook.pre-start etc I settled upon a systemd solution. If your system
happen to use systemd, then e.g. for a container user1 create file
/etc/systemd/units/lxc@user1.service:
.include /lib/systemd/system/lxc@.service
[Unit]
After=mnt-nfs-home.mount
Requires=mnt-nfs-home.mount
[Install]
WantedBy=multi-user.target
(replace mnt-nfs-home.mount with whatever checks you want), then run:
systemctl enable /etc/systemd/units/lxc@user1.service . Deactivation is
handled similarly. Of course, you will have to do everything through
systemd after that, which is why some people believe it is evil and
contagious.
--
With Best Regards,
Marat Khalili
On 23/12/16 08:01, Kees Bos wrote:
Hi,
Is it possible to do some pre-flight checks before starting a
container. E.g. to verify network connectivity before starting the
container, or to check in a central 'database' that the container isn't
running on a different host and register it? Note, that the preflight
check should be able to cancel a startup.
And similar on stopping a container execute some commands e.g. yo
deactivate registration of the container in the central.
Cheers,
Kees
_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users
_______________________________________________
lxc-users mailing list
lxc-users@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-users