visual studio docker compose uses cache


.net webapi app, using docker-compose

a supposedly quick and easy question – how to make visual studio invalidate the docker image and rebuild it? I have tried clearing the solution as well as removing the image container/itself from docker itself – but the visual studio keeps using the cache of some sort

For comparison – when I execute the command manually:

docker-compose build –no-cache

I get an error that the file I am trying to COPY does not exist. This is the expected behavior and the error I would like to see in the visual studio!

COPY [“fileThatDoesNotExist.config”, “.”]

When I rebuild/clean/run the solution in the VisualStudio and the docker-compose run profile is used – it keeps starting up the solution without any errors!

enter image description here

In the build order console window I see the following log

2>#5 [myservice base 2/2] WORKDIR /app
2>#5 CACHED
2>#6 [myservice] exporting to image

It makes no sense for him to keep using the cache because I’ve changed the contents of the dockerfile and it needs to be rebuilt (and expectedly fail)

In docker-compose dcproj file I tried setting the

<DockerComposeBuildArguments>--no-cache</DockerComposeBuildArguments>

but it has no effect whatsoever

so my question is – how to make the visual studio forcefully rebuild the whole image and fail? or alternatively, what can I do in order to clean the cache? (I also don’t want to prune the entirety of docker infrastructure)

Leave a Reply

Your email address will not be published. Required fields are marked *