Running as PID 1

SanderNL

Member
Dec 25, 2022
6
0
6
I'm doing some tinkering with converting a Docker container into an LXC container. Albeit ofcourse via doing some dirty tricks. But nevertheless very educational.
To get the LXC container to run, i've had to install the package `init`. If i now look in the container i see the /sbin/init to be symlink to /lib/systemd/systemd. If i do `ps -aux` i see that `/sbin/init` is running with PID 1.

I now start the LXC container within Proxmox and check for the processes (ps -aux), i can see that "/sbin/init" is running with PID 1. Perfect!

The Docker container makes use of the "s6-overlay" tool for "init". The s6-overlay tool checks for the PID to be `1`. But i'm kind of stuck on this hurdle.
I've provided the config-parameter "lxc.init_cmd: /init".
When i start the LXC container with `pct start 999 --debug` i see the following output:

Code:
NOTICE   conf - ../src/lxc/conf.c:lxc_setup:4511 - The container "999" is set up
INFO     apparmor - ../src/lxc/lsm/apparmor.c:apparmor_process_label_set_at:1189 - Set AppArmor label to "lxc-999_</var/lib/lxc>//&:lxc
-999_<-var-lib-lxc>:"
INFO     apparmor - ../src/lxc/lsm/apparmor.c:apparmor_process_label_set:1234 - Changed AppArmor profile to lxc-999_</var/lib/lxc>//&:l
xc-999_<-var-lib-lxc>:
DEBUG    terminal - ../src/lxc/terminal.c:lxc_terminal_peer_default:696 - No such device - The process does not have a controlling term
inal
NOTICE   utils - ../src/lxc/utils.c:lxc_drop_groups:1367 - Dropped supplimentary groups
NOTICE   start - ../src/lxc/start.c:start:2194 - Exec'ing "/init"
NOTICE   start - ../src/lxc/start.c:post_start:2205 - Started "/init" with pid "1157714"
NOTICE   start - ../src/lxc/start.c:signal_handler:446 - Received 17 from pid 1157699 instead of container init 1157714

But that doesn't work. Is there maybe some more trickery i can try?
 
Last edited:
Never mind... I was actually further along than i thought..
After adding the config of below, i could see that the init-process actually worked :-S
Code:
lxc.init.cmd: /init
lxc.log.level: 3
lxc.console.logfile: /var/log/frigate.log
cat /var/log/frigate.log
I saw there the error:

Code:
Traceback (most recent call last):
  File "/usr/local/go2rtc/create_config.py", line 12, in <module>
    from frigate.ffmpeg_presets import (  # noqa: E402
  File "/opt/frigate/frigate/ffmpeg_presets.py", line 47, in <module>
    if int(os.getenv("LIBAVFORMAT_VERSION_MAJOR", "59")) >= 59
ValueError: invalid literal for int() with base 10: ''
 
I was unknowingly following your footsteps while trying to help someone here: https://forum.proxmox.com/threads/docker-to-pve-lxc-conversion-steps-tool.143193/

I am unsure how you managed to run the Docker entrypoint (script at /init) as PID 1. In the debug output you show, supposedly with the same lxc.init_cmd: /init we see the following:
Code:
NOTICE   start - ../src/lxc/start.c:post_start:2205 - Started "/init" with pid "1157714"
NOTICE   start - ../src/lxc/start.c:signal_handler:446 - Received 17 from pid 1157699 instead of container init 1157714

Indicating that it is running with a pid of 1157714.

What value are you using for cmode inside of the 999.conf LXC config file?

I tried to set the lxc.console.logfile field but no log files are being written, likely because cmode is not console.

I would appreciate it if you get in touch so that we both learn from this. I also find it very intriguing and quite enjoyable.
 
Last edited: