大网数据广告活动
服务器运维问答

docker check if default seccomp profile is applied

· 52CE 我爱测

I wish to know whether or not a specific docker container runs the default seccomp profile. I have no access to the command line which has been used to start the container, nor to the Dockerfile. launching ps aufxwww , i can see …

问题原文

原帖链接 · philippe · CC BY-SA 4.0

I wish to know whether or not a specific docker container runs the default seccomp profile. I have no access to the command line which has been used to start the container, nor to the Dockerfile.

launching ps aufxwww, i can see that the process /usr/bin/dockerd-current has the options --seccomp-profile=/etc/docker/seccomp.json. This is indeed the default seccomp profile file.

However, the process /usr/bin/docker-containerd-current, launching the containerized application, has not. And docker inspect returns : "SecurityOpt": null,.

So which one do I trust ?

EDIT

More surprising, I have run a docker while explicitly specifying a seccomp filter

docker run -d --security-opt seccomp=/etc/docker/seccomp.python.json friendly

and the /proc/$pid/status file returns seccomp 0.

I would have expect instead, according to the man:

2 SECCOMP_MODE_FILTER

社区高分解答

原帖链接 · Hanne Munkholm · CC BY-SA 4.0

I am not an expert and actually found this post because I googled the same question, but I found out this.

If you run Docker with a Seccomp profile, either by specifying nothing and docker will use the default, or by specifying a profile yourself in daemon.json or command line, and you run:

docker run -it alpine /bin/sh
/ # grep Seccomp /proc/1/status
Seccomp:        2

As you can see, you do get to see that the Seccomp filter is on inside the docker. If you explicitly tell docker to run with no Seccomp profile, you get 0.

docker run -it --security-opt seccomp=unconfine alpine /bin/sh
/ # grep Seccomp /proc/1/status
Seccomp:        0

So you can see it from inside the docker. Maybe this makes sense since it is the processes inside the Docker that needs to be confined by the Seccomp profile.

You can also test that a profile does something by downloading the default profile and removing something from it, e.g. chown, and then try:

docker run -it --security-opt seccomp=/etc/docker/myseccomp.json alpine /bin/sh
/ # touch testfile
/ # chown 100.100 testfile
chown: testfile: Operation not permitted

Finally, according to the man page it looks like from kernel 4.14 you can see something in:

/proc/sys/kernel/seccomp/actions_avail

This does not exist in my 4.9 kernel. I hope this is helpful to someone.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。