Skip to content

fix: stop printing the image inspect JSON on destroy - #488

Merged
tas50 merged 1 commit into
mainfrom
fix/quiet-image-exists
Aug 23, 2026
Merged

fix: stop printing the image inspect JSON on destroy#488
tas50 merged 1 commit into
mainfrom
fix/quiet-image-exists

Conversation

@tas50

@tas50 tas50 commented Aug 23, 2026

Copy link
Copy Markdown
Member

image_exists? is the only predicate in the driver that shells out to docker without silencing it. Its three siblings -- container_exists?, container_running?, and image_in_use? -- all pass suppress_output.

So kitchen destroy on an instance with remove_images: true prints the image's entire docker inspect output -- config, environment, every layer digest, metadata, descriptor; about sixty lines of JSON -- in the middle of the destroy output, between the container being removed and the image being removed.

Nothing reads it. Only whether the command succeeded is used.

Before

-----> Destroying <default-ubuntu-2404>...
       [Docker] Destroying Docker container 282c247814fc40dc81b689df0168ec83ee536257f8004ed116257b401688b58d
       282c247814fc40dc81b689df0168ec83ee536257f8004ed116257b401688b58d
       282c247814fc40dc81b689df0168ec83ee536257f8004ed116257b401688b58d
       [
           {
        "Id": "sha256:33c8e9c76cc4d4c1342411aded4f03c30fc69b964074505a1c0f3433c07b84a7",
        "RepoTags": [],
        "RepoDigests": [],
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2026-08-23T16:32:50.994001424Z",
        "Config": { ... },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:646eea22414270d74b0c9e9d6d3b9550701ae62e658a099825d4d15045a3630b",
                ... 16 more ...
            ]
        },
        ...
           }
       ]
       [Docker] Removing image with Image ID sha256:33c8e9c76cc4...
       Deleted: sha256:33c8e9c76cc4...
       Finished destroying <default-ubuntu-2404> (0m0.29s).

After

-----> Destroying <default-ubuntu-2404>...
       [Docker] Destroying Docker container a2ad8e06fe96b8b7515b87f330e8677f5712adb896418fe53cdcda1ab5cfd496
       a2ad8e06fe96b8b7515b87f330e8677f5712adb896418fe53cdcda1ab5cfd496
       a2ad8e06fe96b8b7515b87f330e8677f5712adb896418fe53cdcda1ab5cfd496
       [Docker] Removing image with Image ID sha256:a659812d1948c2baaede157ea045cd61bae082cc48964bc82605b0062d895197.
       Deleted: sha256:a659812d1948c2baaede157ea045cd61bae082cc48964bc82605b0062d895197
       Finished destroying <default-ubuntu-2404> (0m0.31s).

Still printed under -l debug, where the rest of the driver's docker traffic goes -- confirmed in the same run.

The bare ids docker stop and docker rm echo are deliberately left alone: unlike this, they are what those commands report, not a predicate's incidental output.

The method also picked up an early return for the no-image case, so the guard reads the same way as container_exists? and image_in_use? rather than relying on a modifier rescue spanning an &&.

Confirmation

Docker 29.7.2 (Docker Desktop 4.87.0, macOS/arm64), Test Kitchen 4.1.1. Output above is from real kitchen create / kitchen destroy runs against an ubuntu-24.04 container with remove_images: true.

rake style clean; rspec 318 examples, 0 failures (5 new).

`image_exists?` was the only predicate in the driver that shelled out to
docker without silencing it. Its three siblings -- `container_exists?`,
`container_running?`, and `image_in_use?` -- all pass `suppress_output`.

So `kitchen destroy` on an instance with `remove_images` set printed the
image's entire `docker inspect` output -- config, environment, every layer
digest, metadata, descriptor -- some sixty lines of JSON, in the middle of
the destroy output, between the container being removed and the image being
removed:

    -----> Destroying <default-ubuntu-2404>...
           [Docker] Destroying Docker container 282c247814fc...
           [
               {
            "Id": "sha256:33c8e9c76cc4...",
            ...
           ]
           [Docker] Removing image with Image ID sha256:33c8e9c76cc4...

Nothing reads it. Only whether the command succeeded is used.

It is still printed under `-l debug`, where the rest of the driver's docker
traffic goes.

The bare ids `docker stop` and `docker rm` echo are left alone: unlike this,
they are what those commands report, not a predicate's incidental output.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tas50
tas50 merged commit 0011558 into main Aug 23, 2026
107 checks passed
@tas50
tas50 deleted the fix/quiet-image-exists branch August 23, 2026 18:17
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.

1 participant