Docker RUN dotnet Build always cached resulting in consecutive fault

Published

I am currently struggling with Docker builds for .net Core 3.1 where RUN steps are cached, which they should not as this should always be executed:

#10 [build 4/4] RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config
#10 sha256:e8aeefc43305f5ab93d8c8fb78658174bdaa14d42c560daf9d764848da7f251c
#10 CACHED

Which is most likely the cause for the following step to fail: ERROR: "/app/publish" not found: not found:

#14 [final 2/2] COPY --from=base /app/publish .
#14 sha256:4a30ee4113a62bfd40731cdb0cd3a498eaee357df5736019ebd0629bd07f178e
#14 ERROR: "/app/publish" not found: not found

I updated the Docker Desktop on Windows to version 20.10.11, build dea9396, the output of the result looks slightly different, but the same result:

=> CACHED [base 2/2] WORKDIR /app                                                                                 0.0s
=> CACHED [build 2/4] WORKDIR /src                                                                                0.0s
=> CACHED [build 3/4] COPY . .                                                                                    0.0s
=> CACHED [build 4/4] RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -  0.0s

The docker file is quite simple:

FROM registry.intranet.company/ubi8/dotnet-31-runtime AS base

WORKDIR /app
EXPOSE 80

FROM registry.intranet.company/ubi8/dotnet-31 AS build

WORKDIR /src
USER root
COPY . .

RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config

USER default
FROM build AS final

WORKDIR /app
COPY --from=base /app/publish .
ENTRYPOINT ["dotnet", "FrontendWebApplication.UserManagement.dll"]

I’ve already tried the following to solve the issue:

  • Prune all in docker
  • Stop and start Docker Desktop
  • Calling docker build --no-cache
  • Adding the –no-cache option in the RUN statement inside the Dockerfile, like so: RUN dotnet publish "WKIS Solution.sln" -c UserManagementFrontendRelease -p:version=1.2.4 -o /app/publish --configfile FrontendWebApplication.UserManagement.Cicd/nuget.config --no-cache

I am not 100% sure if the cache is responsible for the folder which can’t be found, so the reason might be something complete different, but as I couldn’t find a way to to disable the cache, I simply don’t know and it’s the best guess I have.

Source: Docker Questions

Published
Categorised as .net-core, docker, dockerfile Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq