Fix panic when Docker is unresponsive (Issue #312)#381
Open
aviralgarg05 wants to merge 2 commits intodocker:mainfrom
Open
Fix panic when Docker is unresponsive (Issue #312)#381aviralgarg05 wants to merge 2 commits intodocker:mainfrom
aviralgarg05 wants to merge 2 commits intodocker:mainfrom
Conversation
Pnkcaht
suggested changes
Feb 4, 2026
Contributor
Pnkcaht
left a comment
There was a problem hiding this comment.
Almost perfect, but with a critical bug in ImageExists: it uses the ContainerInspect API instead of ImageInspect, which I think is wrong (containers ≠ images)
Pnkcaht
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Fixes #312
What I did
When Docker Desktop is unresponsive (e.g., paused or exhausted resources), the internal
apiClient()wrapper inpkg/dockerreturnsnil. Previously, the code did not check for this, leading to a nil pointer dereference panic when tools likemcp-addormcp-findattempted to interact with Docker.This PR introduces a safe
client()helper method inpkg/docker/client.gothat checks if the API client is nil and returns a descriptive error ("docker client is not available") instead of panicking.I have updated all files in
pkg/docker(containers.go,images.go,network.go,volumes.go) to use this safe helper.I also added a regression test
TestClientSafeErrorinpkg/docker/client_test.gothat simulates a nil client and verifies that:Verification
go test -v ./pkg/docker/...to verify the fix and ensure no regressions.(not mandatory) A picture of a cute animal
