Skip to content

detect image changes and recreate affected containers#1484

Open
thrawn-sh wants to merge 1 commit into
containers:mainfrom
thrawn-sh:detect-image-changes
Open

detect image changes and recreate affected containers#1484
thrawn-sh wants to merge 1 commit into
containers:mainfrom
thrawn-sh:detect-image-changes

Conversation

@thrawn-sh

Copy link
Copy Markdown
Contributor

podman-compose up currently only compares the YAML config hash to decide whether a container needs to be recreated. This misses the case where an image has been updated (e.g. after a pull) while the compose file itself stays the same — the container keeps running the old image.

Add an image_id field to ExistingContainer, populated from the ImageID returned by podman ps. Before the recreation loop, resolve the current local image ID for each service via podman inspect and compare it against the running container's image ID. When they differ, mark the service for recreation.

Fixes: #1453, #466

@thrawn-sh
thrawn-sh force-pushed the detect-image-changes branch 2 times, most recently from 916f40f to a177c77 Compare June 28, 2026 05:57
self.run_subprocess_assert_returncode([
"podman",
"pull",
"docker.io/library/alpine:latest",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better create nopush/podman-compose-test2. Each pull uses docker free user quota. When running tests many times it's possible to exhaust it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@p12tic: I added another nopush image to the tests, next to the current one, did you want it like this, or as part of the unittest itself?

Comment thread tests/integration/compose_up_behavior/test_compose_up_behavior.py Outdated

@p12tic p12tic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Several small nitpicks, but otherwise looks good.

@@ -0,0 +1 @@
FROM busybox:latest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would FROM nopush/podman-compose-test work here?

@@ -0,0 +1,7 @@
FROM docker.io/library/debian:bookworm-slim

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would FROM nopush/podman-compose-test work here?


# modify the Dockerfile to produce a different image
with open(dockerfile, "w") as f:
f.write("FROM busybox:latest\nRUN touch /marker\n")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FROM nopush/podman-compose-test


finally:
# restore original Dockerfile
with open(dockerfile, "w") as f:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not change files committed to repository, because in this case the source of truth for the file is original_content variable, not what's committed to repository.

Better create the file at the beginning of the test, change however you want and then remove at the end.

@p12tic p12tic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thank you very much and sorry for delayed review. I had only nitpicks regarding test images, otherwise everything is good.

@thrawn-sh

Copy link
Copy Markdown
Contributor Author

I've updated to code according to your suggestions, or at least how I understood them, if still goes in a wrong direction can you please elaborate?

podman-compose up currently only compares the YAML config hash to decide
whether a container needs to be recreated.  This misses the case where an
image has been updated (e.g. after a pull) while the compose file itself
stays the same — the container keeps running the old image.

Add an image_id field to ExistingContainer, populated from the ImageID
returned by podman ps.  Before the recreation loop, resolve the current
local image ID for each service via podman inspect and compare it against
the running container's image ID.  When they differ, mark the service for
recreation.

Fixes: containers#1453, containers#466
Signed-off-by: Alexander Dreweke <alexander@dreweke.net>
@p12tic
p12tic force-pushed the detect-image-changes branch from bca11ab to c17268b Compare July 17, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

up -d does not recreate container after image rebuild (stale image)

2 participants