I'm trying to install a simple linux environment with opam on docker:
$ type .\Dockerfile_Opam.txt
FROM ubuntu:22.04
RUN \
apt-get update -y && \
apt-get install opam -y && \
opam init
Equivalent commands work fine on native linux but with docker I get an error:
$ 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"
CodePudding user response:
OPAM runs builds when installing packages. To guard against buggy makefiles (that might run rm -rf /
by accident), OPAM uses bubblewrap to sandbox the builds. Either install bubblewrap (apt install bubblewrap
) or, if you wish to skip, because you're running in a container anyway, initialize OPAM like this:
opam init --disable-sandboxing