Skip to content

Sudo limitation when building container using Rosetta for x86 emulation #116

Closed

Description

@jaudiger

Here is a simple Dockerfile to reproduce the problem:

###
### Core Image
###
FROM fedora:42

# Create the user
ARG USERNAME=container
ARG USER_UID=1001
ARG USER_GID=${USER_UID}

RUN set -eux; \
    groupadd --gid ${USER_GID} ${USERNAME}; \
    useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}; \
    usermod -a -G wheel ${USERNAME}; \
    echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Switch to the new user
USER ${USERNAME}

WORKDIR /home/${USERNAME}

RUN set -eux; \
   sudo dnf update --refresh -y

When I tried to run the following commands to build a amd64 container, I'm getting a permission error when trying to execute a simple sudo command with the new user:

> container system start
> container build --os linux --arch amd64 -t fedora-image -f "./Dockerfile" .
container run --os linux --arch amd64 --name fedora-devenv --interactive --tty fedora-image
 => ERROR [linux/amd64 3/4] RUN set -eux;    sudo dnf update --refresh -y                                                                                                                                      0.1s
------
 > [linux/amd64 3/4] RUN set -eux;    sudo dnf update --refresh -y:
0.104 + sudo dnf update --refresh -y
0.107 Error while loading /usr/sbin/sudo: Permission denied

Whereas the same building on aarch64 does not produce any error:

> container system start
> container build --os linux -t fedora-image -f "./Dockerfile" .
container run --os linux --name fedora-devenv --interactive --tty fedora-image
 => exporting to oci image format                                                                                                                                                                              0.7s
 => => exporting layers                                                                                                                                                                                        0.0s
 => => exporting manifest sha256:016b55442e346cebbd4c7bc29a296444f62fb02a59e82997658cbb17bc18eeb6                                                                                                              0.0s
 => => exporting config sha256:b499a6caaaa08310ebaafbc42fa8cd80550c629b32559d601a4a7fc752be7dcd                                                                                                                0.0s
 => => exporting manifest list sha256:70adb02856a72a693d3cf2d2e4b5269eea847e8f5d3c3141a0fa1fdfd3ab3fef                                                                                                         0.0s
 => => sending tarball                                                                                                                                                                                         0.7s
Successfully built brioche-package:latest
[container@fedora-devenv ~]$

Any idea of what could be the culprit here ?

Activity

  1. jglogan commented on Jan 14, 2026

    @jglogan
    Contributor

    @jaudiger I just tried reproducing this one on main and don't see this happening for me. If you have time can you check on your end?

    % container build --os linux --arch amd64 -t fedora-image -f Dockerfile .
    Warning! Running debug build. Performance may be degraded.
    [+] Building 37.5s (7/7) FINISHED                                                                                                                                                                               
     => [resolver] fetching image...docker.io/library/fedora:42                                                                                                                                                0.0s
     => [internal] load .dockerignore                                                                                                                                                                          0.0s
     => => transferring context: 2B                                                                                                                                                                            0.0s
     => oci-layout://docker.io/library/fedora:42@sha256:b3d16134560afa00d7cc2a9e4967eb5b954512805f3fe27d8e70bbed078e22ea                                                                                       1.7s
     => => resolve docker.io/library/fedora:42@sha256:b3d16134560afa00d7cc2a9e4967eb5b954512805f3fe27d8e70bbed078e22ea                                                                                         0.1s
     => => sha256:166acd75d0b1af49a6da1a75d47e1bb692d884e14a63f766fd9f2f5a66d40e76 61.15MB / 61.15MB                                                                                                           0.6s
     => => extracting sha256:166acd75d0b1af49a6da1a75d47e1bb692d884e14a63f766fd9f2f5a66d40e76                                                                                                                  1.0s
     => [linux/amd64 1/4] RUN set -eux;     groupadd --gid 1001 container;     useradd --uid 1001 --gid 1001 -m container;     usermod -a -G wheel container;     echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /et  0.4s
     => [linux/amd64 2/4] WORKDIR /home/container                                                                                                                                                              0.0s 
     => [linux/amd64 3/4] RUN set -eux;    sudo dnf update --refresh -y                                                                                                                                       13.9s 
     => exporting to oci image format                                                                                                                                                                          3.2s 
     => => exporting layers                                                                                                                                                                                    2.4s 
     => => exporting manifest sha256:de0b68b4123dfb6fa212dbbbce384b33757f7bcf308a6440ac490d9a6622ffa9                                                                                                          0.0s 
     => => exporting config sha256:fc47672eb5a5813078124734511c87f901c720c4ebff274d33ba6756344124e9                                                                                                            0.0s 
     => => exporting manifest list sha256:7f8a3ef4e1e73d0dd6024e772d791dd1ebfb51233e6f032c5d4bf7174a3f1b78                                                                                                     0.0s 
     => => sending tarball                                                                                                                                                                                     0.8s 
    Successfully built fedora-image:latest
    
    % container run --os linux --arch amd64 --name fedora-devenv --interactive --tty fedora-image
    Warning! Running debug build. Performance may be degraded.
    [container@fedora-devenv ~]$
  2. jaudiger commented on Jan 16, 2026

    @jaudiger
    Author

    Indeed the issue seems to have been resolve since I opened this issue @jglogan:

    ➜ container build --os linux --arch amd64 -t fedora-image -f "./Dockerfile" .
    [+] Building 30.6s (7/7) FINISHED
     => [resolver] fetching image...docker.io/library/fedora:42                                                                                                                                                                                                                                                                                                                  0.0s
     => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                            0.1s
     => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                              0.1s
     => oci-layout://docker.io/library/fedora:42@sha256:b3d16134560afa00d7cc2a9e4967eb5b954512805f3fe27d8e70bbed078e22ea                                                                                                                                                                                                                                                         1.7s
     => => resolve docker.io/library/fedora:42@sha256:b3d16134560afa00d7cc2a9e4967eb5b954512805f3fe27d8e70bbed078e22ea                                                                                                                                                                                                                                                           0.0s
     => => sha256:166acd75d0b1af49a6da1a75d47e1bb692d884e14a63f766fd9f2f5a66d40e76 61.15MB / 61.15MB                                                                                                                                                                                                                                                                             0.5s
     => => extracting sha256:166acd75d0b1af49a6da1a75d47e1bb692d884e14a63f766fd9f2f5a66d40e76                                                                                                                                                                                                                                                                                    1.2s
     => [linux/amd64 1/4] RUN set -eux;     groupadd --gid 1001 container;     useradd --uid 1001 --gid 1001 -m container;     usermod -a -G wheel container;     echo '%wheel ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers                                                                                                                                                           0.5s
     => [linux/amd64 2/4] WORKDIR /home/container                                                                                                                                                                                                                                                                                                                                0.0s
     => [linux/amd64 3/4] RUN set -eux;     sudo dnf update --refresh -y                                                                                                                                                                                                                                                                                                        17.3s
     => exporting to oci image format                                                                                                                                                                                                                                                                                                                                            4.0s
     => => exporting layers                                                                                                                                                                                                                                                                                                                                                      3.1s
     => => exporting manifest sha256:bb4e9db397ef41199a7fc00ed45b7f0199aad27b9ad09112df8bde2c60ca5ef0                                                                                                                                                                                                                                                                            0.0s
     => => exporting config sha256:e50626ef9617bd500e3c246679d5bfd1132009b6bff8a9c3f29cdda54f35a87e                                                                                                                                                                                                                                                                              0.0s
     => => exporting manifest list sha256:37996815672aba6a9f7a74c367933aa44755f66c4cd1f943420fc44e576650cb                                                                                                                                                                                                                                                                       0.0s
     => => sending tarball                                                                                                                                                                                                                                                                                                                                                       0.9s
    Successfully built fedora-image:latest
    

    Thanks for the reminder, I'll close the ticket.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions