Skip to content

docker_compose: normalize image names before comparing with docker ps - #1089

Open
wardhus wants to merge 1 commit into
puppetlabs:mainfrom
wardhus:compose-normalize-image
Open

wardhus wants to merge 1 commit into
puppetlabs:mainfrom
wardhus:compose-normalize-image

Conversation

@wardhus

@wardhus wardhus commented Oct 27, 2026 •

Copy link
Copy Markdown

docker compose config prints fully qualified image names such as docker.io/library/postgres:18-alpine, while docker ps prints the short familiar form (postgres:18-alpine). The exists? check compared the two strings literally, so any project whose compose file uses a docker.io/ prefix was never seen as running and docker compose up was executed on every Puppet run.

Strip the implicit Docker Hub prefixes from the configured image name so the comparison matches. Also route the explicit image: case through get_image so the normalization applies there too.

Fixes #967

Summary

Provide a detailed description of all the changes present in this pull request.

Additional Context

Add any additional context about the problem here.

  • Root cause and the steps to reproduce. (If applicable)
  • Thought process behind the implementation.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@wardhus
wardhus requested a review from a team as a code owner October 27, 2026 09:55
@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jst-cyr

jst-cyr commented Oct 28, 2026

Copy link
Copy Markdown
Member

Thank you for submitting the PR, @wardhus .

I authorized the CI to run and it looks like we have a Rubocop failure:

Error: Lint/UnusedBlockArgument: Unused block argument - array. If it's necessary, use _or_array as an argument name to indicate that it won't be used. ([https://rubystyle.guide#underscore-unused-vars](https://rubystyle.guide/#underscore-unused-vars))

This seems to be caused by removing the use of array later in the function. Are you able to fix that up, please?

`docker compose config` prints fully qualified image names such as
docker.io/library/postgres:18-alpine, while `docker ps` prints the
short familiar form (postgres:18-alpine). The exists? check compared
the two strings literally, so any project whose compose file uses a
docker.io/ prefix was never seen as running and `docker compose up`
was executed on every Puppet run.

Strip the implicit Docker Hub prefixes from the configured image name
so the comparison matches. Also route the explicit `image:` case
through get_image so the normalization applies there too.

Fixes puppetlabs#967
@wardhus
wardhus force-pushed the compose-normalize-image branch from 42a3fd5 to 004ff82 Compare October 29, 2026 10:21
@wardhus

wardhus commented Oct 29, 2026

Copy link
Copy Markdown
Author

Should be fine now :)

@jst-cyr

jst-cyr commented Oct 29, 2026

Copy link
Copy Markdown
Member

Thanks @wardhus ! I've approved the basic CI to run so we should get some initial feedback from Rubocop and unit tests against 8.0.

If that looks good, I'll trigger off an acceptance test branch to run the full suite.

@jst-cyr

jst-cyr commented Oct 29, 2026

Copy link
Copy Markdown
Member

Running CI tests for this PR here: #1090

@jst-cyr

jst-cyr commented Oct 29, 2026

Copy link
Copy Markdown
Member

🟢 Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-docker/actions/runs/40922351147?pr=1090

All green! Tests have passed for all platforms. Needs engineering review.

This branch has not been deployed

No deployments
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.

Docker compose restarting service with docker.io/library/ container

3 participants