次のコマンドラインを使用してUbuntu 14.04でuserns(非特権)LXCコンテナーを作成する場合:
lxc-create -n test1 -t download -- -d $(lsb_release -si|tr 'A-Z' 'a-z') -r $(lsb_release -sc) -a $(dpkg --print-architecture)
(作成された構成ファイルを変更せずに)次のコマンドで開始しようとします。
lxc-start -n test1 -l DEBUG
それは失敗します。ログファイルは私を示しています:
lxc-start 1420149317.700 INFO lxc_start_ui - using rcfile /home/user/.local/share/lxc/test1/config
lxc-start 1420149317.700 INFO lxc_utils - XDG_RUNTIME_DIR isn't set in the environment.
lxc-start 1420149317.701 INFO lxc_confile - read uid map: type u nsid 0 hostid 100000 range 65536
lxc-start 1420149317.701 INFO lxc_confile - read uid map: type g nsid 0 hostid 100000 range 65536
lxc-start 1420149317.701 WARN lxc_log - lxc_log_init called with log already initialized
lxc-start 1420149317.701 INFO lxc_lsm - LSM security driver AppArmor
lxc-start 1420149317.701 INFO lxc_utils - XDG_RUNTIME_DIR isn't set in the environment.
lxc-start 1420149317.702 DEBUG lxc_conf - allocated pty '/dev/pts/2' (5/6)
lxc-start 1420149317.702 DEBUG lxc_conf - allocated pty '/dev/pts/7' (7/8)
lxc-start 1420149317.702 DEBUG lxc_conf - allocated pty '/dev/pts/8' (9/10)
lxc-start 1420149317.702 DEBUG lxc_conf - allocated pty '/dev/pts/10' (11/12)
lxc-start 1420149317.702 INFO lxc_conf - tty's configured
lxc-start 1420149317.702 DEBUG lxc_start - sigchild handler set
lxc-start 1420149317.702 DEBUG lxc_console - opening /dev/tty for console peer
lxc-start 1420149317.702 DEBUG lxc_console - using '/dev/tty' as console
lxc-start 1420149317.702 DEBUG lxc_console - 14946 got SIGWINCH fd 17
lxc-start 1420149317.702 DEBUG lxc_console - set winsz dstfd:14 cols:118 rows:61
lxc-start 1420149317.905 INFO lxc_start - 'test1' is initialized
lxc-start 1420149317.906 DEBUG lxc_start - Not dropping cap_sys_boot or watching utmp
lxc-start 1420149317.906 INFO lxc_start - Cloning a new user namespace
lxc-start 1420149317.906 INFO lxc_cgroup - cgroup driver cgmanager initing for test1
lxc-start 1420149317.907 ERROR lxc_cgmanager - call to cgmanager_create_sync failed: invalid request
lxc-start 1420149317.907 ERROR lxc_cgmanager - Failed to create hugetlb:test1
lxc-start 1420149317.907 ERROR lxc_cgmanager - Error creating cgroup hugetlb:test1
lxc-start 1420149317.907 INFO lxc_cgmanager - cgroup removal attempt: hugetlb:test1 did not exist
lxc-start 1420149317.908 INFO lxc_cgmanager - cgroup removal attempt: perf_event:test1 did not exist
lxc-start 1420149317.908 INFO lxc_cgmanager - cgroup removal attempt: blkio:test1 did not exist
lxc-start 1420149317.908 INFO lxc_cgmanager - cgroup removal attempt: freezer:test1 did not exist
lxc-start 1420149317.909 INFO lxc_cgmanager - cgroup removal attempt: devices:test1 did not exist
lxc-start 1420149317.909 INFO lxc_cgmanager - cgroup removal attempt: memory:test1 did not exist
lxc-start 1420149317.909 INFO lxc_cgmanager - cgroup removal attempt: cpuacct:test1 did not exist
lxc-start 1420149317.909 INFO lxc_cgmanager - cgroup removal attempt: cpu:test1 did not exist
lxc-start 1420149317.910 INFO lxc_cgmanager - cgroup removal attempt: cpuset:test1 did not exist
lxc-start 1420149317.910 INFO lxc_cgmanager - cgroup removal attempt: name=systemd:test1 did not exist
lxc-start 1420149317.910 ERROR lxc_start - failed creating cgroups
lxc-start 1420149317.910 INFO lxc_utils - XDG_RUNTIME_DIR isn't set in the environment.
lxc-start 1420149317.910 ERROR lxc_start - failed to spawn 'test1'
lxc-start 1420149317.910 INFO lxc_utils - XDG_RUNTIME_DIR isn't set in the environment.
lxc-start 1420149317.910 INFO lxc_utils - XDG_RUNTIME_DIR isn't set in the environment.
lxc-start 1420149317.910 ERROR lxc_start_ui - The container failed to start.
lxc-start 1420149317.910 ERROR lxc_start_ui - Additional information can be obtained by setting the --logfile and --logpriority options.
ここで2つのエラーが表示されます。後者はおそらく前者の結果です。
lxc_start-cgroupの作成に失敗しました
しかし、私は/sys/fs/cgroup
マウントされているのを見ます:
$ mount|grep cgr
none on /sys/fs/cgroup type tmpfs (rw)
そしてcgmanager
インストールされています:
$ dpkg -l|awk '$1 ~ /^ii$/ && /cgmanager/ {print $2 " " $3 " " $4}'
cgmanager 0.24-0ubuntu7 amd64
libcgmanager0:amd64 0.24-0ubuntu7 amd64
注:ホストのデフォルトはのままupstart
です。
疑問がある場合は、カーネルサポートcgroups
:
$ grep CGROUP /boot/config-$(uname -r)
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NET_CLS_CGROUP=m
CONFIG_NETPRIO_CGROUP=m
注:ホストのデフォルトはのままupstart
です。
WARN: could not reopen tty: Permission denied
。しかしsudo -H -i -u database lxc-start -n mysql -d
、あなたの質問のように開始は失敗します。同じエラー。ただし、修正はで機能しませんsudo
。私がしなければsudo -H -i -u database cat /proc/self/cgroup
私は私を呼び出すユーザーとして、それを実行した場合とまったく同じ出力を得ます。ですから、sudoを使用してコンテナーを起動しようとすると、他のユーザーがcgroupに書き込みを試みて失敗します... :-(洞察は何か?