Skip to content

Ensure sudo works in cross-arch Docker image builds#6074

Open
axelfontaine wants to merge 3 commits into
basecamp:devfrom
axelfontaine:docker-multiplatform-perms
Open

Ensure sudo works in cross-arch Docker image builds#6074
axelfontaine wants to merge 3 commits into
basecamp:devfrom
axelfontaine:docker-multiplatform-perms

Conversation

@axelfontaine

@axelfontaine axelfontaine commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Setup

Run a cross-arch Docker image build with a Dockerfile containing a USER directive and sudo:

FROM alpine:latest

RUN apk add --no-cache sudo && \
    adduser -D appuser && \
    echo "appuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER appuser

CMD ["sudo", "whoami"]

using the following command:

docker build --platform linux/arm64 -t sudo-test . && docker run --platform linux/arm64 --rm sudo-test

Before

It fails with:

sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

After

It succeeds as expected and prints:

root

Copilot AI review requested due to automatic review settings June 11, 2026 14:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a workaround so sudo works during cross-platform Docker image builds by adjusting the host’s binfmt/qemu configuration.

Changes:

  • Introduces a migration script to patch qemu-*-static.conf and restart systemd-binfmt.
  • Adds the same sed patch to the Docker install/config script.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
migrations/1780929365.sh New migration to update binfmt qemu config and restart systemd-binfmt.
install/config/docker.sh Applies the same binfmt config edit during Docker configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread migrations/1780929365.sh
Comment thread install/config/docker.sh Outdated
Comment thread migrations/1780929365.sh
Comment thread install/config/docker.sh
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