I am having issues with building a dotnet core image. When I run docker pull mcr.microsoft.com/dotnet/sdk:3.1, this works but my dockerfile build is throwing the error 'failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed' when I do a docker build -t weatherapi -f Dockerfile . Here's my dockerfile below
FROM mcr.microsoft.com/dotnet/sdk:3.1
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o out
FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app
EXPOSE 80
COPY --from=build /app/out .
ENTRYPOINT ["dotnet" "weather.dll"]
It looks like you've got a multi-stage Dockerfile but haven't named any stages. Specifically, the COPY --from=build /app/out . line references a stage named build that is not defined. This should resolve the issue (note the first line defines the build stage):
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -c release -o out
FROM mcr.microsoft.com/dotnet/aspnet:3.1
WORKDIR /app
EXPOSE 80
COPY --from=build /app/out .
ENTRYPOINT ["dotnet" "weather.dll"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With