DeepVAC / MLab

“云上炼丹师”中的云
GNU General Public License v3.0
67 stars 16 forks source link

[bug] 运行homepod 1.1的时候报错:Error response from daemon: AppArmor enabled on system but the docker-default profile could not be loaded: strconv.Atoi: parsing "file": invalid syntax. #20

Closed gemfield closed 3 years ago

gemfield commented 3 years ago

错误如下:

gemfield@ThinkPad-X1C:~$ docker run -it --rm -p 5900:5900 -p 7030:7030 -v /app/gemfield:/app/gemfield -v /home/gemfield/github:/home/gemfield/github gemfield/homepod:1.1 bash
docker: Error response from daemon: AppArmor enabled on system but the docker-default profile could not be loaded: strconv.Atoi: parsing "file": invalid syntax.
gemfield commented 3 years ago

这是在Ubuntu 20.10上(有可能20.04也受到影响),使用了最新版的docker ce出现的问题。这是docker ce的bug,临时解决方案:

  1. 新增/etc/apparmor.d/docker文件
  2. 文件内容为:
    #include <tunables/global>
    profile docker-default flags=(attach_disconnected,mediate_deleted) {
    #include <abstractions/base>
    network,
    capability,
    file,
    umount,
    deny @{PROC}/* w,   # deny write for all files directly in /proc (not in a subdir)
    # deny write to files not in /proc/<number>/** or /proc/sys/**
    deny @{PROC}/{[^1-9],[^1-9][^0-9],[^1-9s][^0-9y][^0-9s],[^1-9][^0-9][^0-9][^0-9]*}/** w,
    deny @{PROC}/sys/[^k]** w,  # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)
    deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w,  # deny everything except shm* in /proc/sys/kernel/
    deny @{PROC}/sysrq-trigger rwklx,
    deny @{PROC}/mem rwklx,
    deny @{PROC}/kmem rwklx,
    deny @{PROC}/kcore rwklx,
    deny mount,
    deny /sys/[^f]*/** wklx,
    deny /sys/f[^s]*/** wklx,
    deny /sys/fs/[^c]*/** wklx,
    deny /sys/fs/c[^g]*/** wklx,
    deny /sys/fs/cg[^r]*/** wklx,
    deny /sys/firmware/efi/efivars/** rwklx,
    deny /sys/kernel/security/** rwklx,
    # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container ptrace (trace,read) peer=docker-default,
    }
  3. 重启apparmor
    /etc/init.d/apparmor restart