I have extended the default version of docker-compose.yml
to add a few additional containers which run alongside the main container which the Torizon Extension in Visual Studio Code manages and where it deploys and debugs the main project. This is working really well: if I start with a blank Colibri module then when I press F5 in Visual Studio Code it will build all of the container images, deploy them to the module and start running all of the required containers.
My question is about how to automatically update the container images when I change the dockerfile or other source files for a container. If I edit the dockerfile and then start a debug session in Visual Studio Code what I see is that the main container for the firmware is rebuilt if necessary, but my changes to the dockerfile for the secondary container is ignored.
I can see the image for the container on the Colibri module. If I delete the image from the Colibri before starting a new debug session then Visual Studio Code will rebuild the image with the changes that I made and deploy it. I can see the progress in the Visual Studio Code terminal as my image is being built. That does work, but it’s tedious to do it this way and it’s easy to end up with stale containers. And it doesn’t work well in a team environment as I might not notice that a colleague has updated the source code for a container which means it needs to be rebuilt.
Is there a mechanism to force docker-compose
to rebuild a container? As part of my build process I do have a script run which detects if the container source code has changed, so if there is way to force a rebuild then I can do it in that script.
My first thought was to simply have my script delete the stale image so that it needs to be rebuilt, but the image for my secondary container does not appear in the list of images present on my PC. I do see the image for the main container. This may be related to this topic:
macos - I can’t find my Docker image after building it - Stack Overflow
(I’m not using macos, but that topic still seems relevant)