lxc 容器启动失败怎么回事?

log:

  lxc-start 1599145069.560 INFO     lxc_start_ui - lxc_start.c:main:265 - using rcfile /usr/var/lib/lxc/openwrt/config
  lxc-start 1599145069.561 WARN     lxc_confile - confile.c:config_personality:989 - unsupported personality 'ARM'
  lxc-start 1599145069.561 WARN     lxc_log - log.c:lxc_log_init:316 - lxc_log_init called with log already initialized
  lxc-start 1599145069.562 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup blkio unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.562 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup CPU unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup CPUacct unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup CPUset unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup devices unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup freezer unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup memory unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup net_cls unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup net_prio unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.563 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup perf_event unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.565 INFO     lxc_start - start.c:lxc_check_inherited:209 - closed inherited fd 4
  lxc-start 1599145069.575 INFO     lxc_conf - conf.c:run_script_argv:350 - Executing script '/usr/var/lib/lxc/openwrt/pre-start.sh' for container 'openwrt', config section 'lxc'
  lxc-start 1599145069.596 INFO     lxc_start - start.c:lxc_check_inherited:209 - closed inherited fd 4
  lxc-start 1599145069.613 INFO     lxc_monitor - monitor.c:lxc_monitor_sock_name:177 - using monitor sock name lxc/8518417411765f46//usr/var/lib/lxc
  lxc-start 1599145069.635 DEBUG    lxc_conf - conf.c:lxc_create_tty:3666 - allocated pty '/dev/pts/0' (5/6)
  lxc-start 1599145069.635 INFO     lxc_conf - conf.c:lxc_create_tty:3677 - tty's configured
  lxc-start 1599145069.635 DEBUG    lxc_start - start.c:setup_signal_fd:247 - sigchild handler set
  lxc-start 1599145069.635 DEBUG    lxc_console - console.c:lxc_console_peer_default:536 - no console peer
  lxc-start 1599145069.635 INFO     lxc_start - start.c:lxc_init:443 - 'openwrt' is initialized
  lxc-start 1599145069.636 DEBUG    lxc_start - start.c:__lxc_start:1059 - Not dropping cap_sys_boot or watching utmp
  lxc-start 1599145069.637 INFO     lxc_cgroup - cgroup.c:cgroup_init:62 - cgroup driver cgroupfs initing for openwrt
  lxc-start 1599145069.639 INFO     lxc_start - start.c:lxc_spawn:891 - clone_flags:0x2c020000
  lxc-start 1599145069.642 ERROR    lxc_cgfs - cgfs.c:lxc_cgroupfs_enter:1163 - Invalid argument - Could not add pid 1775 to cgroup /lxc/openwrt: internal error
  lxc-start 1599145069.643 ERROR    lxc_start - start.c:__lxc_start:1081 - failed to spawn 'openwrt'
  lxc-start 1599145069.648 WARN     lxc_commands - commands.c:lxc_cmd_rsp_recv:172 - command get_cgroup failed to receive response
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup blkio unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup CPU unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup CPUacct unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup cpuset unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup devices unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.648 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup freezer unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.649 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup memory unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.649 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup net_cls unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.649 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup net_prio unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145069.649 WARN     lxc_cgfs - cgfs.c:lxc_cgroup_get_container_info:1100 - Not attaching to cgroup perf_event unknown to /usr/var/lib/lxc openwrt
  lxc-start 1599145074.660 ERROR    lxc_start_ui - lxc_start.c:main:342 - The container failed to start.
  lxc-start 1599145074.660 ERROR    lxc_start_ui - lxc_start.c:main:344 - To get more details, run the container in foreground mode.
  lxc-start 1599145074.660 ERROR    lxc_start_ui - lxc_start.c:main:346 - Additional information can be obtained by setting the --logfile and --logpriority options.

config:

lxc.arch = ARM
lxc.utsname = openwrt
lxc.rootfs.mount = /usr/var/lib/lxc/openwrt/rootfs
lxc.rootfs.path = overlayfs:/opt/upt/framework1/rootfs:/opt/upt/apps/openwrt-rootfs 
# lxc.rootfs = /usr/var/lib/lxc/openwrt/rootfs 
lxc.haltsignal = SIGUSR1
lxc.tty = 1
lxc.pts = 1
lxc.hook.pre-start = /usr/var/lib/lxc/openwrt/pre-start.sh
lxc.aa_profile = lxc-container-default-with-nesting

lxc.network.type = none
lxc.mount.entry = sysfs sys sysfs defaults 0 0
lxc.mount.auto = cgroup-full:rw
lxc.mount.entry = proc proc proc defaults 0 0
lxc.mount.entry = /mnt mnt none rw,rbind 0 0
lxc.start.auto = 1

pre-start.sh:

#!/bin/sh

umount /dev/pts /dev/ptmx

mount -t devpts -o newinstance -o ptmxmode=0666,nosuid devpts /dev/pts
mount -o bind /dev/pts/ptmx /dev/ptmx

咦 LXC 可以直接指定别的 arch 起容器吗?

完全不清楚但似乎是有这个键值…
去掉?

去掉或者指定成宿主机一样的 arch 试试呗,我没这样直接用过 LXC 但印象中直接用宿主机内核好像没听说能直接支持跨 arch 的执行来着,另外 openwrt 是有 x86_64 的可能你用的 rootfs 也要换一下

LXC 适用的场景是不需要不同的内核…你的场景可能需要 qemu…

这是光猫……
骚操作 hack 一下……
总之他们的实例都是建立在 LXC 上的……
当然你可以删掉容器天翼 ** 搞上 openwrt

@ 维格纳的朋友
https://GitHub.com/lxc/lxc/blob/3a9018bba747a13e0930df8cf82a86ad687f2aa4/src/lxc/confile.c

反正 lxc 支持的 architecture 都在这个 confile.c 的 lxc_config_parse_arch() 函数里,至于函数里的 PER_Linux32 和 PER_Linux 来自于 /usr/include/sys/personality.h

你可以把那个函数提取出来单独编译一个 main.c 然后放你光猫上跑一跑…那些个 arch name 哪个 >= 0 你的 config 里就用哪个…