Installing dune in opam Debian docker container on arm host for platform amd64

On an apple silicon macos, given the following repro.dockerfile:

FROM ocaml/opam:debian-ocaml-5.1
ENV DEBIAN_FRONTEND=noninteractive
RUN opam install dune.3.16.0 -y

running

docker build -f repro.dockerfile -t debug-dune .

runs successfully

But running the same for platform linux/amd64:

docker buildx build -f repro.dockerfile --platform linux/amd64 -t debug-dune .

fails:

7.794 <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
12.05 [ERROR] The compilation of dune failed at "/home/opam/.opam/5.1/bin/ocaml boot/bootstrap.ml -j 39".
12.05
12.05 #=== ERROR while compiling dune.3.16.0 ========================================#
12.05 # context              2.0.10 | linux/x86_64 | ocaml-base-compiler.5.1.1 | file:///home/opam/opam-repository
12.05 # path                 ~/.opam/5.1/.opam-switch/build/dune.3.16.0
12.05 # command              ~/.opam/5.1/bin/ocaml boot/bootstrap.ml -j 39
12.05 # exit-code            255
12.05 # env-file             ~/.opam/log/dune-7-60459a.env
12.05 # output-file          ~/.opam/log/dune-7-60459a.out
12.05 ### output ###
12.05 # ocamlc -output-complete-exe -w -24 -g -o .duneboot.exe -I boot -I +unix unix.cma boot/libs.ml boot/duneboot.ml
12.05 # ./.duneboot.exe -j 39
12.05 # cd _boot && /home/opam/.opam/5.1/bin/ocamlopt.opt -c -g -no-alias-deps -w -49-6 -alert -unstable -I +unix -I +threads opamLineLexer.ml
12.05 #
12.05
12.05
12.05
12.05 <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
12.05 +- The following actions failed
12.05 | - build dune 3.16.0
12.05 +-
12.05 - No changes have been performed

My goal is to build an application on an arm mac, so it works on amd64 debian.
Any idea why installing dune specifically might not work? Running opam install ... for packages works

This looks like OOM. I don’t use docker but podman and I was able to reproduce. podman was more explicit about OOM though:

Killed
Error: building at STEP "RUN opam install dune.3.16.0 -y": while running runtime: exit status 137

You need to increase the docker machine memory. I did this (normally replacing podman with docker should work):

podman machine stop 
podman machine set --memory 4096 # 4GB it was 2GB before
podman machine inspect # Check that looks ok
podman machine start

Then your buildx invocation was long but succeeded.

1 Like

thanks, this helped!

  • I increased the memory of my docker container from 8 to 13GB and it worked
  • I hadn’t used podman, tried it and opam install dune worked out-of-the-box (2GB machine), but the whole container was times slower to reach that point, and it seems it doesn’t have the same layers cache as docker, not sure

Interesting. I don’t have particular opinion on docker vs podman. podman was sold to me as needing less privileges on my machine and since both cli are compatible and that I’m very gullible I just went with that.

well, I haven’t used podman before, but I’m using it now, because I’m encountering less problems with installations (which I would have though should be identical between docker and podman)