在 docker 容器内运行 pppd 时出错

在 docker 容器内运行 pppd 时出错

我有一个 docker 容器,想在其中运行 pppd。主机内核有CONFIG_PPP=y。我正在像这样设置 ppp 设备:

mkdir /run/container/dev
mknod /run/container/dev c 108 0
... add some more devices here ...

然后我使用卷挂载启动容器/run/container/dev:/dev。容器以 root 身份运行--privileged,容器内的进程也以 root 身份运行。

当我尝试在容器内运行 pppd 时,失败了:

/ # pppd
Couldn't open the /dev/ppp device: Operation not permitted
pppd: Sorry - this system lacks PPP kernel support

strace表明问题出EPERM在尝试打开时/dev/ppp

openat(AT_FDCWD, "/dev/ppp", O_RDWR|O_LARGEFILE) = -1 EPERM (Operation not permitted)
getpid()                                = 76
sendto(3, "<27>Jul 14 09:55:08 pppd[76]: Co"..., 89, 0, NULL, 0) = -1 ENOTCONN (Socket not connected)
connect(3, {sa_family=AF_UNIX, sun_path="/dev/log"}, 12) = -1 EPROTOTYPE (Protocol wrong type for socket)
write(1, "Couldn't open the /dev/ppp devic"..., 58Couldn't open the /dev/ppp device: Operation not permitted) = 58
write(1, "\n", 1
)                       = 1
writev(2, [{iov_base="pppd: Sorry - this system lacks "..., iov_len=52}, {iov_base=NULL, iov_len=0}], 2pppd: Sorry - this system lacks PPP kernel support

) = 52
getpid()                                = 76
sendto(3, "<27>Jul 14 09:55:08 pppd[76]: So"..., 75, 0, NULL, 0) = -1 ENOTCONN (Socket not connected)
connect(3, {sa_family=AF_UNIX, sun_path="/dev/log"}, 12) = -1 EPROTOTYPE (Protocol wrong type for socket)
exit_group(4)                           = ?

我在这里遗漏了什么?

答案1

最终将其追溯到需要--device-cgroup-rule="c 108:0 rwm"docker命令行。

相关内容