microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
175 stars 26 forks source link

container-tools stale old image cache #298

Closed X-BiLe closed 1 month ago

X-BiLe commented 3 years ago

At running the risk of sounding ignorant, i am having an issue with my images never being updated after the initial container is created. What i am doing is I am creating an empty solution, then i add a docker enabled web or api project then add the container orchestration support and update my yml. i then modify my yml to include mariadb like so:

version: '3.4'

services:
    db:
        image: mariadb:latest        
        container_name: mariadb
        environment:
            MYSQL_ROOT_PASSWORD: Passw0rd!
        ports:
            - 3306:3306
        restart: always

    dockertest.web:
        image: ${DOCKER_REGISTRY-}dockertestweb:latest
        build:
            context: .
            dockerfile: DockerTest.Web/Dockerfile
        depends_on:
            - db
        ports:
            - 5000:80

once saved, container tools automatically executes the yml and creates the images and the container without issue. however, should i make a change to the web or api project and rebuild the image when container tools tries to run the yml again, it never uses the updated image instead it always used the previously cached image and i see:

#4 [base 2/2] WORKDIR /app
#4 sha256:c2f91b6b815d749f2097010f07c8aa22854aa0332b209b441219f7c1e792cc1a
#4 CACHED

i have done everything i can think, docker rmi all images, rm all containers, prune, "docker-compose down --rmi all", but its like its stored somewhere i have not been able to track down. i do know that if i run the docker-compose.yml directly the current image is used without issues. Any thoughts on what i may be doing wrong or how to dump the images from the cache it would be greatly appreciated.

NCarlsonMSFT commented 3 years ago

@X-BiLe Most likely you are just seeing the performance optimizations for debugging: https://aka.ms/containerfastmode#debugging In the Debug configuration VS volume mounts the files as built on the host machine so that you don't need to rebuild the image for each run. If you prefer to have the full image built each time you can use the Release configuration.