Skip to content

Segmentation fault building project on dotnet/sdk:7.0 image with Apple M1 #4225

@jon-mca

Description

@jon-mca

Describe the Bug

Running into a problem where creating a docker image from mcr.microsoft.com/dotnet/sdk:7.0 on an M1 Apple MacBook Pro throws a segmentation fault from package qemu during publish.

ERROR [publish 8/8] RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish --self-conta  6.7s
 > [publish 8/8] RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish --self-contained -r linux-x64:
#15 2.836 MSBuild version 17.4.0+18d5aef85 for .NET
#15 6.456 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#15 6.729 Segmentation fault

The docker file looks like this, which worked previously with the .NET Core 6 SDK image (changed to point to 7.0 images):

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS publish
WORKDIR /src
COPY [".", "."]
WORKDIR "/src/MyProject"
RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish --self-contained -r linux-x64

FROM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["./MyProject"]

My suspicion is that the SDK 7.0 base image that is being pulled from docker is not the ARM64 tagged variant, .i.e. Linux Arm64, and what is being used is not compatiable with the the M1.

Steps to Reproduce

Run dockerfile on an M1 equipped Apple Mac computer.

Other Information

A workaround for this issue is to explicity set the SDK base image to use the Linux Arm64 (7.0-bullseye-slim-arm64v8) tagged SDK image:

FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim-arm64v8 AS publish
WORKDIR /src
COPY [".", "."]
WORKDIR "/src/MyProject"
RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish --self-contained -r linux-x64

FROM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["./MyProject"]

...or a better workaround example is to provide the tag to use via --build-arg and pass "7.0-bullseye-slim-arm64v8" as a value otherwise it'll default to "7.0":

ARG SDK_TAG=7.0
FROM mcr.microsoft.com/dotnet/sdk:${SDK_TAG} AS publish
WORKDIR /src
COPY [".", "."]
WORKDIR "/src/MyProject"
RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish --self-contained -r linux-x64

FROM mcr.microsoft.com/dotnet/runtime-deps:7.0 AS final
WORKDIR /app
COPY --from=publish /app/publish .
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["./MyProject"]

Output of docker version

Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.19.2
 Git commit:        baeda1f82a
 Built:             Tue Oct 25 17:53:02 2022
 OS/Arch:           darwin/arm64
 Context:           desktop-linux
 Experimental:      true

Server: Docker Desktop 4.14.1 (91661)
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 17:59:41 2022
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.9
  GitCommit:        1c90a442489720eec95342e1789ee8a5e1b9536f
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info

Client:
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.12.2)
  dev: Docker Dev Environments (Docker Inc., v0.0.3)
  extension: Manages Docker extensions (Docker Inc., v0.2.13)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.21.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 17
 Server Version: 20.10.21
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.15.49-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 6
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: CNTH:R6D7:QFEW:INEF:X2VS:DWGM:JCQF:HCQG:OO3S:J4P2:J7YX:A4XF
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions