2023-10-30 updateAllContainers() function is wrong #744
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The following post appeared on Discord:
This is an extract of the relevant function:
There are several problems with this command sequence:
There is no need to down the stack while downloading images and/or rebuilding containers is occurring.
The
pull
command is correct. It deals with service definitions containingimage:
clauses, queries DockerHub for updates, and downloads any more-recent images it finds.The
build
command is incorrect because it simply re-runs Dockerfiles on top of already-downloaded base images to produce new local images. In its current form, this command will never query DockerHub to download a more-recent base image. This command needs to be expressed as:The "up" command is correct. When issued, any newly-downloaded (by the
pull
) or newly-rebuilt (by thebuild
) images will be instantiated as running containers, with new-for-old container swaps occurring at the last moment, resulting in negligible downtime.There is also a command missing from the sequence, which is:
That cleans up old local images and build artifacts.
The absence of the
--no-cache --pull
flags from thebuild
command is the direct cause of the problem reported on Discord:The old base image for Node-RED was retained.
The Dockerfile was re-run.
The Dockerfile run caused updated versions of the add-on nodes to be downloaded.
The
node-red-contrib-home-assistant-websocket
node required version of Node-RED 14 while only version 12 was available - because thebuild
had not forced an up-to-date base image.