I am trying to generate a Docker Image without using Visual Studio. I am in the project folder and I execute from windows 10 admin command line
docker build . I can’t figure out how to make this work.
[+] Building 1.3s (8/9) => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 753B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 34B 0.0s => [internal] load metadata for mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s => [base 1/2] FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim 0.0s => ERROR FROM docker.io/publish/app:latest 1.2s => => resolve docker.io/publish/app:latest 1.2s => CACHED [base 2/2] WORKDIR /app 0.0s => CACHED [final 1/2] WORKDIR /app 0.0s => [auth] publish/app:pull token for registry-1.docker.io 0.0s ------ > FROM docker.io/publish/app:latest: ------ failed to load cache key: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
This 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/core/aspnet:3.1-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443 FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["src/App.Web/App.Web.csproj", "src/App.Web/"] RUN dotnet restore "App.Web.csproj" COPY . . WORKDIR "/src/App.Web" RUN dotnet build App.Web.csproj -c Debug -o /app FROM build as debug RUN dotnet publish "App.Web.csproj" -c Debug -o /app FROM base as final WORKDIR /app COPY --from=publish/app /app . ENTRYPOINT ["dotnet","App.Web.dll"]
You have stages called base, build, and debug. Then in the final stage you have:
COPY --from=publish/app /app .
When docker can’t find the stage with that name,
publish/app, it tries to find that image, which doesn’t exist. I’m guessing you want to copy from the build stage, e.g.
COPY --from=build /app .