skip to Main Content

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"

2

Answers


  1. 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
    
    Login or Signup to reply.
  2. This also works but idk if its safe or the cons/pros with the disabling sandbox option:

    USER root
    RUN apt-get update && apt-get install -y --no-install-recommends bubblewrap
    RUN opam init
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search