在 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 命令列上找到了這一點。

相關內容