Skip to content

fix: read the image id from a quiet build - #489

Merged
tas50 merged 1 commit into
mainfrom
fix/quiet-build-image-id
Aug 24, 2026
Merged

fix: read the image id from a quiet build#489
tas50 merged 1 commit into
mainfrom
fix/quiet-build-image-id

Conversation

@tas50

@tas50 tas50 commented Aug 23, 2026

Copy link
Copy Markdown
Member

Fixes #225 — nine years old and still reproducible.

The bug

docker build -q prints the id on a line of its own and nothing else:

$ docker build -q -f Dockerfile .
sha256:ab86ce908a36ffb7de411a72550e416a4d8c268570a0f7313c284c79344d6c0f

No step lines, no exporting to image, no writing image, no naming to, no Successfully built — none of the wording parse_image_id matches on. So every pattern missed, and build_options: -q failed after the image had already been built:

>>>>>> Message: Could not parse Docker build output for image ID

The fix

A line that is nothing but a digest is read as the id.

It has to be the whole line. Ordinary build output is full of #6 exporting manifest sha256:... done lines, so matching a digest anywhere would pick one of those instead — there is a spec pinning that.

The fixture is captured from a real docker build -q on 29.7.2, like the others in spec/support/docker_output.rb.

Confirmation

Docker 29.7.2 (Docker Desktop 4.87.0, macOS/arm64), Test Kitchen 4.1.1, real ubuntu-24.04 container, driver: {build_options: -q}.

Before:

>>>>>> Message: 1 actions failed.
       Could not parse Docker build output for image ID
       image_id=nil

After:

       Finished creating <quietbuild-ubuntu-2404> (0m1.40s).
       HELLO FROM PROVISIONER
       Finished converging <quietbuild-ubuntu-2404> (0m0.60s).
       image_id=sha256:9270df1e2707659a9fa55b8aac0ed440545736f175bcc90f2dad59af54234d0e

Ordinary (non--q) builds still parse — checked in the same run.

rake style clean; rspec 316 examples, 0 failures (3 new).

Fixes #225.

`docker build -q` prints the id on a line of its own and nothing else -- no
step lines, no "exporting to image", none of the wording parse_image_id
matches on. So `build_options: -q` never produced an instance; it failed
with

    Could not parse Docker build output for image ID

after the image had already been built.

A line that is nothing but a digest is now read as the id. It has to be the
whole line: ordinary build output is full of "... sha256:... done" lines, and
matching a digest anywhere would pick one of those instead.

The fixture is captured from a real `docker build -q` on 29.7.2, as the
others in that file are.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tas50
tas50 force-pushed the fix/quiet-build-image-id branch from a264811 to 6ebe0a2 Compare August 23, 2026 19:44
@tas50
tas50 merged commit ddc58b5 into main Aug 24, 2026
213 of 214 checks passed
@tas50
tas50 deleted the fix/quiet-build-image-id branch August 24, 2026 00:50
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.

"Could not parse Docker build output for image ID" in docker version 1.12.1 using build_options -q

1 participant