Skip to content

Anchor VERSION match on the Docker epoch to avoid distro-version hits - #571

Open
fudianchn wants to merge 1 commit into
docker:masterfrom
fudianchn:fix-version-selection-distro-match
Open

Anchor VERSION match on the Docker epoch to avoid distro-version hits#571
fudianchn wants to merge 1 commit into
docker:masterfrom
fudianchn:fix-version-selection-distro-match

Conversation

@fudianchn

@fudianchn fudianchn commented Aug 9, 2026

Copy link
Copy Markdown

Problem

On Ubuntu noble, VERSION=24.0 installs the latest Docker (28.4.0) instead of the requested 24.0 (#526):

INFO: apt-cache madison docker-ce | grep '24.0' | head -1 | ...

The grep matches VERSION anywhere in the madison line, so 24.0 matches the 24.04 in 5:28.4.0-1~ubuntu.24.04~noble, and head -1 then resolves to 28.4.0.

Fix

Anchor the grep on the madison version field, with the Docker epoch (5:) optional:

- search_command="apt-cache madison docker-ce | grep '$pkg_pattern' | head -1 | ..."
+ search_command="apt-cache madison docker-ce | grep -E ' \\| (5:)?$pkg_pattern' | head -1 | ..."

Applied to both the docker-ce and docker-ce-cli lookups. The version field always starts right after the | separator, so the pattern binds to the start of the package version and cannot match the distro version embedded in the release suffix. The epoch is optional because deb packages before 18.03 (17.x) were published without the 5: epoch, and those pins keep working.

Verification

Simulated apt-cache madison docker-ce output (noble) with both 28.4.0 and 24.0.2 present, VERSION=24.0:

grep selected (cut -f3)
grep '24.0' (before) 5:28.4.0-1~ubuntu.24.04~noble (wrong: matched 24.04)
grep -E ' \| (5:)?24.0' (after) 5:24.0.9-1~ubuntu.24.04~noble (correct)
grep -E ' \| (5:)?17.03' (after, pre-epoch package) 17.03.2~ce-0~ubuntu-xenial (correct)

And when 24.0 is genuinely unavailable, the anchored grep matches nothing -> the script hits its existing ERROR: '$VERSION' not found amongst apt-cache madison results path and exits 1, instead of silently installing the latest.

bash -n install.sh passes; the matching table above is produced by running the exact pipeline from install.sh against the simulated madison output. The repository CI (including shellcheck) has not run on this fork PR yet and will execute once approved.

Closes #526

@742764146

742764146 commented Aug 9, 2026 via email

Copy link
Copy Markdown

@fudianchn
fudianchn force-pushed the fix-version-selection-distro-match branch 2 times, most recently from 5a33dc2 to 7509207 Compare August 13, 2026 04:27
…o-version hits

Anchor the apt-cache madison grep on the version field separator with an
optional Docker epoch (5:), so VERSION matches the start of the package
version instead of the distro version inside the release suffix. Packages
published before 18.03 carry no epoch and keep matching.

Closes docker#526

Signed-off-by: 付典 <fudianchn@gmail.com>
@fudianchn
fudianchn force-pushed the fix-version-selection-distro-match branch from 7509207 to 47885b1 Compare August 15, 2026 15:19
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.

version-selection fails if the version matches the distro version

2 participants