I have an M1 macbook running Docker Desktop 4.14.1.
I have created a dot net asp.net website project. When I build my image for arm64 everything works fine. When I try to build for amd64 the build gets hung up on the dotnet restore command.
I have tried building using both the normal docker build and also docker buildx build. The buildx build gives other errors that I can’t seem to resolve either, so I decided to post here and focus on the dotnet restore hanging up to see if there is a solution to that without using buildx. If there is not then I will start a new thread to ask about the buildx errors.
Here is my dockerfile:
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["MyApp.Server/MyApp.Server.csproj", "MyApp.Server/"]
COPY ["MyApp/MyApp.csproj", "MyApp/"]
COPY ["MyApp.Api.User/MyApp.Api.User.csproj", "MyApp.Api.User/"]
COPY ["MyApp.Api.Models/MyApp.Api.Models.csproj", "MyApp.Api.Models/"]
COPY ["MyApp.Configuration/MyApp.Configuration.csproj", "MyApp.Configuration/"]
COPY ["MyApp.User.Services/MyApp.User.Services.csproj", "MyApp.User.Services/"]
COPY ["MyApp.Api.Data/MyApp.Api.Data.csproj", "MyApp.Api.Data/"]
COPY ["MyApp.User/MyApp.User.csproj", "MyApp.User/"]
RUN dotnet restore "MyApp.Server/MyApp.Server.csproj"
COPY . .
WORKDIR "/src/MyApp.Server"
RUN dotnet build "MyApp.Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyApp.Server.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyApp.Server.dll"]
Here is my command line I am using to build for amd64:
docker build -f MyApp.Server/Dockerfile --platform linux/amd64 .