Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build docker using Macbook M1 #3122

Closed
minhtienvu opened this issue Sep 10, 2021 · 2 comments
Closed

Unable to build docker using Macbook M1 #3122

minhtienvu opened this issue Sep 10, 2021 · 2 comments

Comments

@minhtienvu
Copy link

minhtienvu commented Sep 10, 2021

Describe the Bug

I have a problem with RUN dotnet store when I build the containers. I use Macbook M1 to do it.
When I do it with my case using Linux system. It's done but with my Macbook M1, it's terrible. It took me 3 days to fix it but I don't have any solutions. Can you give me some ideas to fix it?

Screen Shot 2021-09-10 at 10 22 29

Steps to Reproduce

Other Information

My Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine3.10 AS build
WORKDIR /src
COPY ["Buildee.Canvas.SignalR/Buildee.Canvas.SignalR.csproj", "Buildee.Canvas.SignalR/"]
COPY ["Buildee.Canvas/Buildee.Canvas.csproj", "Buildee.Canvas/"]
COPY ["Buildee.System.Diagnostics.Metrics/Buildee.System.Diagnostics.Metrics.csproj", "Buildee.System.Diagnostics.Metrics/"]
RUN dotnet restore "Buildee.Canvas.SignalR/Buildee.Canvas.SignalR.csproj"
COPY . .
WORKDIR "/src/Buildee.Canvas.SignalR"
RUN dotnet build "Buildee.Canvas.SignalR.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Buildee.Canvas.SignalR.csproj" -c Release -o /app

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine3.10 AS final
WORKDIR /app
ENV ASPNETCORE_URLS=http://*:5000 \
    Serilog__WriteTo__0__Args__formatter="Serilog.Formatting.Json.JsonFormatter, Serilog"
RUN apk update && apk upgrade && apk add --no-cache jq
COPY --from=publish /app .
ADD Buildee.Canvas.SignalR/scripts/script.sh /usr/local/bin/script.sh
RUN chmod 755 /usr/local/bin/script.sh

EXPOSE 5000

ENTRYPOINT ["script.sh"]

Output of docker version

Client:
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:55:20 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:53:34 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-rc.2)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 7
  Running: 0
  Paused: 0
  Stopped: 7
 Images: 19
 Server Version: 20.10.8
 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: 1
 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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e25210fe30a0a703442421b0f60afac609f950a3
 runc version: v1.0.1-0-g4144b63
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.47-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 4
 Total Memory: 7.765GiB
 Name: docker-desktop
 ID: BW7W:UEEU:OMPT:33AE:QFTD:NN2A:UT4S:PDK4:Z23H:KOMJ:34Z4:T3TS
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
@mthalman
Copy link
Member

This is because the 3.1-alpine3.10 tag you're targeting is for the amd64 architecture while the M1 Macbook uses arm64 architecture. This causes Docker to use the QEMU emulator which is not currently supported by .NET (see dotnet/runtime#47280).

Instead, it's recommended to use an arm64-specific tag (e.g. 3.1-alpine-arm64v8) if you're targeting .NET Core 3.1 or a multi-arch tag (e.g. 5.0-alpine) if you're targeting .NET 5.0.

I see that you're targeting Alpine 3.10. That version is no longer being supported for the .NET Docker images. You can see the list of currently supported tags for ASP.NET Core at https://hub.docker.com/_/microsoft-dotnet-aspnet/. If you were to use the 3.1-alpine-arm64v8 tag, you'd always be on the latest supported version of Alpine.

@MichaelSimons
Copy link
Member

[Triage] Closing per @mthalman's answer.

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

No branches or pull requests

3 participants