Restart-policy containers loop on "unable to apply apparmor profile" after reboot until the creating user logs in (OCI hook inherits the client's XDG_RUNTIME_DIR)
メンテナーはふだん 3 日以内に返信
評価
調査の方向性
Start by tracing withNerdctlOCIHook and the createRuntime hook's loadAppArmor() path, then inspect how the hook environment supplies XDG_RUNTIME_DIR to containerd's LoadDefaultProfile. Reproduce with the issue's restart-policy steps and an unset runtime directory. Done when rootful containers restart after reboot without the creating user logging in, with a regression test covering the missing runtime directory.
索引モデルが issue の本文から書いたものです。
説明
Description
After a reboot, rootful containers with a restart policy loop on:
runc create failed: ... unable to apply apparmor profile: apparmor failed to apply profile: write /proc/self/attr/apparmor/exec: no such file or directory
They recover on their own as soon as the user who created them logs in.
Cause: withNerdctlOCIHook stores the client's whole os.Environ() as the hooks' env. The createRuntime hook's loadAppArmor() calls containerd's LoadDefaultProfile, which writes its temp file to os.CreateTemp(os.Getenv("XDG_RUNTIME_DIR"), ...). If the containers were created over SSH, that path is something like /run/user/0, which doesn't exist after boot until that user logs in. The load fails (logged only in oci-hook.createRuntime.log), and runc then fails with the error above:
failed to load AppArmor profile "nerdctl-default" error="open /run/user/4242/nerdctl-default3219038152: no such file or directory"
Steps to reproduce the issue
As root, with no other nerdctl containers restarting meanwhile:
nerdctl apparmor load
XDG_RUNTIME_DIR=/run/user/4242 nerdctl run -d --name aa-repro --restart=always alpine sleep infinity
echo -n nerdctl-default > /sys/kernel/security/apparmor/.remove # simulate reboot
kill -9 "$(nerdctl inspect aa-repro --format '{{.State.Pid}}')"
nerdctl logs aa-repro # fails every ~10 s
mkdir -m 700 /run/user/4242 # simulate login: container starts within seconds
Describe the results you received and expected
Expected: containers start after boot without anyone logging in. Possible fixes: don't put XDG_RUNTIME_DIR in the hook env (rootful), or fall back to os.TempDir() when it's missing.
Workaround: a oneshot systemd unit that runs nerdctl apparmor load, ordered Before=containerd.service.
What version of nerdctl are you using?
v2.3.5 (reproduced). Same code in v2.4.2.
Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
Host information
Debian 13, kernel 6.12.117, AppArmor 4.1.0, containerd v2.3.3, runc 1.5.1, rootful.
- 主要言語
- Go
- スター
- 10.5k
- フォーク
- 853
- 平均マージ
- 6日 14時間
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
containerd/nerdctl のほかの issue
-
Test and examples: update wordpress images (to silence potential false security alerts)対応中かも @Guurdeep が 20 日前に担当しました。 オープンarea/ci documentation priority/low
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
containerd/nerdctl#5283 · コメント 2 件 ·
メンテナーはふだん 3 日以内に返信
-
`nerdctl kill` shouldn't set `containerd.io/restart.explicitly-stopped` label for non-stop signals再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
containerd/nerdctl#5171 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
area/project
難易度 1/5 1時間未満 初心者へのやさしさ 25/100
containerd/nerdctl#5383 · コメント 5 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
containerd/nerdctl#5355 ·
メンテナーはふだん 3 日以内に返信
-
v2.4.3 planningオープンarea/project
難易度 5/5 1週間以上 初心者へのやさしさ 12/100
containerd/nerdctl#5353 · リアクション 2 件 ·
メンテナーはふだん 3 日以内に返信
containerd/nerdctl の issue をすべて見る
似ている issue
-
P3 tech debt
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
kind/feature needs-triage priority/unprioritized
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
NVIDIA/k8s-test-infra#1504 ·
メンテナーはふだん 1 日以内に返信
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
wso2/agent-manager#2717 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
open-policy-agent/opa#9685 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信