opam init 在 docker 上失败

opam init fails on docker

我正在尝试在 [=25 上使用 opam 安装一个简单的 linux 环境=]:

$ type .\Dockerfile_Opam.txt
FROM ubuntu:22.04
RUN                        \
apt-get update -y       && \
apt-get install opam -y && \
opam init

等效命令 在本机 linux 上运行良好,但在 docker 上我得到一个错误:

$ docker build --tag host --file .\Dockerfile_Opam.txt .
# ... omitted for brevity ...
#5 48.09 [ERROR] Sandboxing is not working on your platform ubuntu:
#5 48.09         "~/.opam/opam-init/hooks/sandbox.sh build sh -c echo SUCCESS >$TMPDIR/opam-sandbox-check-out && cat $TMPDIR/opam-sandbox-check-out; rm -f $TMPDIR/opam-sandbox-check-out" exited with code 1 "bwrap: Creating new namespace failed: Operation not permitted"

OPAM 运行s 在安装包时构建。为了防止错误的 makefile(可能 运行 rm -rf / 意外),OPAM 使用 bubblewrap 对构建进行沙箱处理。安装 bubblewrap (apt install bubblewrap),或者,如果你想跳过,因为你 运行 宁在容器中,像这样初始化 OPAM:

opam init --disable-sandboxing