what happens on "reboot"?

23 views
Skip to first unread message

Harald Dunkel

unread,
Sep 22, 2021, 2:25:01 AM9/22/21
to lxc-...@lists.linuxcontainers.org
Hi folks,

maybe a stupid question (about lxd and "old" lxc):

If I run "reboot" in the container, then it will get a new init
process, AFAICT. Will it also get a new namespace, new cgroup
mounts, new capabilities, etc. according to the current lxc
config file? Probably reboot is not the same as

lxc-stop -n myhost
lxc-start -n myhost

but what are the differences?

I'd love to see the container uptime in the output of lxc-ls
--fancy (similar to docker ps, but using hours, minutes and
seconds).


Regards
Harri

Stéphane Graber

unread,
Sep 22, 2021, 5:48:18 PM9/22/21
to Harald Dunkel, LXC users mailing-list
Christian can confirm for traditional LXC/liblxc but there I would
expect that we keep the configuration as it is, tear down the
namespace and spawn init again in an identically configured set of
namespaces.

LXD is a bit different because we want to allow for reconfiguring on
reboots and we have a bunch of things that can happen on the LXD side
too, like snapshots on reboot, complex network/storage setups, ..
So in the LXD case, we configure liblxc to completely kill the
container during a reboot, then notify LXD about it (through a
post-stop hook) and then LXD will start the container again as if it
was freshly started.
> --
> You received this message because you are subscribed to the Google Groups "lxc-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lxc-users+...@lists.linuxcontainers.org.
> To view this discussion on the web visit https://groups.google.com/a/lists.linuxcontainers.org/d/msgid/lxc-users/4c0b29c0-ca26-39eb-8e49-703e60ea30f2%40aixigo.com.

Serge E. Hallyn

unread,
Sep 22, 2021, 8:41:03 PM9/22/21
to Stéphane Graber, Harald Dunkel, LXC users mailing-list
Hi,

you can trace the boot+reboot path at src/lxc/lxccontainer.c around
line 1093. Under the reboot: label there is lxc_start, then below that
if it detects the container is rebooting, it jumps back to the reboot:
label. lxc_start -> __lxc_start -> lxc_spawn -> do_start, which is
where the namespaces - other than preexisting ones which you requested
be shared of course - will be created etc.

-serge
> To view this discussion on the web visit https://groups.google.com/a/lists.linuxcontainers.org/d/msgid/lxc-users/CA%2Benf%3DtqugvUSobK-Yi97_SEq7PrAasM647Lm2UsGNf7dUzJ_g%40mail.gmail.com.

Harald Dunkel

unread,
Sep 24, 2021, 5:18:35 AM9/24/21
to Stéphane Graber, LXC users mailing-list
On 2021-09-22 23:48:01, Stéphane Graber wrote:
>
> LXD is a bit different because we want to allow for reconfiguring on
> reboots and we have a bunch of things that can happen on the LXD side
> too, like snapshots on reboot, complex network/storage setups, ..
> So in the LXD case, we configure liblxc to completely kill the
> container during a reboot, then notify LXD about it (through a
> post-stop hook) and then LXD will start the container again as if it
> was freshly started.
>

Would it be possible to get something like this into lxc 5?

I'd love *so* much to replace lxc by lxd on Debian, but snaps are not an
option. Since 2011 I am using lxc on my systems.

Thank you for your reply. Please keep on with your good work


Harri
Reply all
Reply to author
Forward
0 new messages