无法在容器上应用 AppArmor 配置文件:"no such file or directory"

Can't apply AppArmor profile on container: "no such file or directory"

我正在尝试应用以下简单的 AppArmor 配置文件:

#include <tunables/global>

profile docker-profile flags=(attach_disconnected,mediate_deleted) {
  #include <abstractions/base>
  #network,
  #capability,
  #file,
  #umount,
  #ptrace,
  #mount,
  pivot_root,
}

当我 运行 docker run -it --rm --security-opt apparmor=docker-profile alpine 我得到以下错误:

docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"process_linux.go:359: container init caused \"apparmor failed to apply profile: no such file or directory\"\"\n".

我尝试重新安装它(根据建议here):

rm -rf /etc/apparmor*
apt install apparmor --reinstall
service apparmor restart
service docker restart

它没有帮助,我仍然遇到同样的错误。

任何建议可能是什么原因以及如何解决它?

我需要通过 运行 apparmor_parser -r -W docker.profile 注册个人资料。

可在此处找到更多信息:
https://docs.docker.com/engine/security/apparmor/

sudo apt-get purge apparmor sudo apt-get purge apparmor-profiles sudo apt-get purge apparmor-utils

sudo apt-get install apparmor-utils sudo apt install apparmor-profiles apparmor-profiles-extra vim-addon-manager

重启