Docker 的 privileged 模式
无论是 docker 启动一个 container 还是在 k8s 中 deploy 一个 Pod 都可以指定 privileged 参数,之前在 Pod 的 spec YAML file 也里曾经用过,但是一直没有仔细想过加上这个参数后有什么不一样,今天就来研究一下。 首先来看一个最直观的对比,先运行一个没有 privileged 的容器: $ docker run --rm -it ubuntu:18.04 bash root@e6f5f42c5b7e:/# ls /dev/ console core fd full mqueue null ptmx pts root@e6f5f42c5b7e:/# fdisk -l 再来看看如果加上了 privileged 会有什么不一样: $ docker run --rm -it --privileged ubuntu:18.04 bash root@8e28f79eec9e:/# ls /dev/ tty11 tty2 tty28 tty36 tty44 tty52 tty60 ... ... root@8e28f79eec9e:/# fdisk -l Disk /dev/loop0: 97.1 MiB, 101777408 bytes, 198784 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes 不止能看到设备文件,甚至还能 mount 宿主机的文件系统, ...