I try to build an Docker container on Mac M1 with the DFX SDK for Motoko.
Here is my Dockerfile:
FROM --platform=linux/amd64 node:20-bookworm-slim
# Install a basic environment needed for our build tools
RUN apt-get -yq update && \
apt-get -yqq install --no-install-recommends \
curl \
ca-certificates \
build-essential \
pkg-config \
libssl-dev \
llvm-dev \
liblmdb-dev \
clang \
cmake \
rsync \
git \
libunwind-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install dfx
RUN DFX_VERSION=0.24.1 DFXVM_INIT_YES=true sh -ci "$(curl -fsSL https://internetcomputer.org/install.sh)"
ENV PATH="/root/.local/share/dfx/bin:$PATH"
# Verify installation
RUN dfx --version
When I try to start the Docker image, I encounter several errors, and after a short time, the replica stops with an error:
My docker-compose.yaml file looks like:
version: '3.8'
services:
icp-dev-env:
image: icp-dev-env-mac:latest
container_name: icp-dev-env
platform: linux/amd64
working_dir: /root/app
volumes:
- .:/root/app
command: tail -f /dev/null
After starting the local replica, I face the following prints:
root@f3d3547dd3ea:~/app# dfx start --background
Running dfx start for version 0.24.1
Using the default configuration for the local shared network.
Installed dfx 0.24.1 to cache.
<jemalloc>: MADV_DONTNEED does not work (memset will be used instead)
<jemalloc>: (This is the expected behaviour if you are running under QEMU)
Initialized replica.
Initialized HTTP gateway.
Replica API running on 127.0.0.1:4943
And after a deployment try I get the following sandbox error:
Deploying all canisters.
Creating canisters...
Creating canister backend...
Creating a wallet canister on the local network.
Sandbox pid 163 for canister Some(thread 'MR Batch ProcessorProcessInfo' panicked at rs/canister_sandbox/src/replica_controller/sandboxed_execution_controller.rs:902: { 34:
called `Result::unwrap()` on an `Err` value: ServerError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
canister_id: Some(CanisterId(bnz7o-iuaaa-aaaaa-qaaaa-caiqemu: uncaught target signal 6 (Aborted) - core dumped
)), panic_on_failure: true }) exited unexpectedly with status Signaled(Pid(163), SIGKILL, false)
thread '<unnamed>' panicked at rs/canister_sandbox/src/launcher.rs:151:38:
called `Result::unwrap()` on an `Err` value: ServerError
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
qemu: uncaught target signal 6 (Aborted) - core dumped
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to register all canisters.
Caused by: Failed to create canister 'backend'.
Caused by: Failed to create wallet
Caused by: Failed while installing wasm.
Caused by: The replica returned an HTTP Error: Http Error: status 502 Bad Gateway, content type "text/plain; charset=utf-8", content: connection_failure: client error (SendRequest)
root@f3d3547dd3ea:~/app# <jemalloc>: MADV_DONTNEED does not work (memset will be used instead)
<jemalloc>: (This is the expected behaviour if you are running under QEMU)
How can I resolve this and successfully build a Docker image on an M1 Mac?
I’d appreciate any guidance in the right direction. Thank you!