Skip to content

fix: resolve macOS/Apple Silicon Docker build failures#1131

Open
pastudan wants to merge 1 commit intothemactep:masterfrom
pastudan:fix-macos-docker-build
Open

fix: resolve macOS/Apple Silicon Docker build failures#1131
pastudan wants to merge 1 commit intothemactep:masterfrom
pastudan:fix-macos-docker-build

Conversation

@pastudan
Copy link
Copy Markdown

@pastudan pastudan commented Mar 25, 2026

Problem

Building on macOS with Docker Desktop fails in two ways:

1. groupadd: GID '20' already exists (Dockerfile)

macOS passes the host GID (20 = "staff") into the container. That GID already exists in the Debian base image, so groupadd exits with code 4 and the entire build layer fails.

ERROR [6/8] RUN groupadd -g 20 builder && ...
0.035 groupadd: GID '20' already exists

Fix: append 2>/dev/null || true to groupadd so the existing group is silently reused.


2. rsync: failed to hard-link … Operation not permitted (Makefile.docker)

Buildroot's per-package isolation uses rsync --hard-links to snapshot the staging tree between packages. Hard links across a Docker bind-mount backed by an APFS volume (macOS host) are not supported by the macOS filesystem layer, causing every package build to fail.

rsync: failed to hard-link … Operation not permitted (1)
make[1]: *** [...] Error 1

Fix: mount the build output directory as a named Docker volume (thingino-build-output) that lives entirely inside the Docker Linux VM, where hard links work normally. The host filesystem is no longer in the rsync path.

A docker-extract-images target is also added to copy the finished thingino-*.bin files back to ./images/ on the host after a successful build.

Testing

Tested on macOS 26.3 (Apple Silicon, M4) with Docker Desktop. Both issues are resolved and a full firmware build completes successfully.

Usage (after this fix)

# Build (output stays in named Docker volume)
CAMERA=your_camera_name ./docker-build.sh build

# Copy finished firmware to ./images/ on the host
make -f Makefile.docker docker-extract-images

Made with Cursor

Two issues prevent building on macOS with Docker Desktop:

1. **Dockerfile** (`groupadd` GID collision): macOS GID 20 ("staff") is
   passed into the container via `--userns` and already exists in the
   Debian image. `groupadd` exits with code 4, aborting the build.
   Fix: append `2>/dev/null || true` so the existing group is reused.

2. **Makefile.docker** (APFS hard-link limitation): Buildroot's
   per-package isolation uses `rsync --hard-links` to snapshot the
   staging tree. Hard links across a bind-mounted APFS volume (the macOS
   host filesystem) are not supported and cause `rsync: failed to
   hard-link … Operation not permitted` errors.
   Fix: mount the build output directory as a named Docker volume
   (`thingino-build-output`) that lives entirely inside the Linux VM,
   where hard links work. Also adds a `docker-extract-images` target to
   copy the finished `.bin` files back to the host `./images/` directory.

Made-with: Cursor
@alextrical
Copy link
Copy Markdown

I'm also experiencing the same issue as you.
I don't think Fix: append 2>/dev/null || true to groupadd so the existing group is silently reused.
is quite the right solution. the command should be creating the group number 1000, yet somehow the variable is coming through as 20

There where also the following issues on my macbook pro m1:
arm64 not being supported,
gdd instead of dd,
dependencies not being installed with brew
setting user group to 1000
These have been addressed in the branch https://github.com/alextrical/thingino-firmware-mac/tree/fix-macos-docker-build

I do however have an issue with the Podman Volume, on first run it creates the files as expected, however on the second run the system fails due to permissions being unable to remove the files in the volume.
It is only fixable by removing the volume between runs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants