Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opam init fails on docker

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"
like image 311
OrenIshShalom Avatar asked Nov 05 '25 10:11

OrenIshShalom


1 Answers

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-get install bubblewrap) or, if you wish to skip, because you're running in a container anyway, initialize OPAM like this:

opam init --disable-sandboxing
like image 167
corwin.amber Avatar answered Nov 07 '25 07:11

corwin.amber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!