From 12c5392b29a140be5718c54a8af04caf36aefaca Mon Sep 17 00:00:00 2001 From: xyzhou Date: Wed, 19 Feb 2025 21:09:43 +0800 Subject: [PATCH] =?UTF-8?q?update=20docs\docs\zh\docs\Container\=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E7=89=B9=E6=80=A7.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改格式 Changes to be committed: modified: docs/zh/docs/Container/安全特性.md Signed-off-by: xyzhou --- ...11\345\205\250\347\211\271\346\200\247.md" | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git "a/docs/zh/docs/Container/\345\256\211\345\205\250\347\211\271\346\200\247.md" "b/docs/zh/docs/Container/\345\256\211\345\205\250\347\211\271\346\200\247.md" index 3865f4cae..785933733 100644 --- "a/docs/zh/docs/Container/\345\256\211\345\205\250\347\211\271\346\200\247.md" +++ "b/docs/zh/docs/Container/\345\256\211\345\205\250\347\211\271\346\200\247.md" @@ -31,7 +31,7 @@ seccomp(**secure computing** **mode**)是linux kernel从2.6.23版本开始 通过--security-opt将配置文件传给要过滤系统调用的容器。 -``` +```shell isula run -itd --security-opt seccomp=/path/to/seccomp/profile.json rnd-dockerhub.huawei.com/official/busybox ``` @@ -45,7 +45,7 @@ isula run -itd --security-opt seccomp=/path/to/seccomp/profile.json rnd-dockerhu - 启动一个普通容器(或者是带--cap-add的容器),并查看默认权限配置: - ``` + ```shell cat /etc/isulad/seccomp_default.json | python -m json.tool > profile.json ``` @@ -80,7 +80,7 @@ isula run -itd --security-opt seccomp=/path/to/seccomp/profile.json rnd-dockerhu - 查看转换为lxc可识别的seccomp配置 - ``` + ```shell cat /var/lib/isulad/engines/lcr/74353e38021c29314188e29ba8c1830a4677ffe5c4decda77a1e0853ec8197cd/seccomp ``` @@ -103,7 +103,7 @@ isula run -itd --security-opt seccomp=/path/to/seccomp/profile.json rnd-dockerhu 在启动容器的时候使用--security-opt引入seccomp配置文件,容器实例会按照配置文件规则进行限制系统API的运行。首先获取普通容器的默认seccomp,得到完整模板,然后按照本节定制配置文件,启动容器: -``` +```shell isula run --rm -it --security-opt seccomp:/path/to/seccomp/profile.json rnd-dockerhub.huawei.com/official/busybox ``` @@ -152,7 +152,7 @@ isula run --rm -it --security-opt seccomp:/path/to/seccomp/profile.json rnd-dock capabilities机制是linux kernel 2.2之后引入的安全特性,用更小的粒度控制超级管理员权限,可以避免使用 root 权限,将root用户的权限细分为不同的领域,可以分别启用或禁用。capabilities详细信息可通过Linux Programmer's Manual进行查看([capabilities\(7\) - Linux man page](http://man7.org/linux/man-pages/man7/capabilities.7.html)): -``` +```shell man capabilities ``` @@ -184,7 +184,7 @@ man capabilities iSulad使用--cap-add/--cap-drop给容器增加/删去特定的权限,在非必要情况下,不要给容器增加额外的权限,推荐将容器默认但非必要的权限也去掉。 -``` +```shell isula run --rm -it --cap-add all --cap-drop SYS_ADMIN rnd-dockerhub.huawei.com/official/busybox ``` @@ -204,7 +204,7 @@ SELinux\(Security-Enhanced Linux\)是一个Linux内核的安全模块,提供 >![](./public_sys-resources/icon-note.gif) **说明:** >- 目前iSulad不支持对容器的文件系统打标签,确保容器文件系统及配置目录打上容器可访问标签,需使用chcon命令对其打上标签。 >- 若iSulad启用SELinux访问控制,建议daemon启动前对/var/lib/isulad目录打上标签,容器容器创建时目录下生产的文件及文件夹将默认继承其标签,例如: -> ``` +> ```shell > chcon -R system_u:object_r:container_file_t:s0 /var/lib/isulad > ``` @@ -212,7 +212,7 @@ SELinux\(Security-Enhanced Linux\)是一个Linux内核的安全模块,提供 - daemon端使能selinux: - ``` + ```shell isulad --selinux-enabled ``` @@ -231,7 +231,7 @@ SELinux\(Security-Enhanced Linux\)是一个Linux内核的安全模块,提供 --security-opt="label=disable" 容器禁用SELinux配置 - ``` + ```shell $ isula run -itd --security-opt label=type:container_t --security-opt label=level:s0:c1,c2 rnd-dockerhub.huawei.com/official/centos 9be82878a67e36c826b67f5c7261c881ff926a352f92998b654bc8e1c6eec370 ``` @@ -241,7 +241,7 @@ SELinux\(Security-Enhanced Linux\)是一个Linux内核的安全模块,提供 - 为挂载卷打selinux标签\('z'为共享模式\) - ``` + ```shell $ isula run -itd -v /test:/test:z rnd-dockerhub.huawei.com/official/centos 9be82878a67e36c826b67f5c7261c881ff926a352f92998b654bc8e1c6eec370 -- Gitee