Skip to content

Fix: Enable Docker authentication for custom image registries (#39)#1041

Open
Nikky000 wants to merge 1 commit intodocker:mainfrom
Nikky000:fix/docker-auth-issue-39
Open

Fix: Enable Docker authentication for custom image registries (#39)#1041
Nikky000 wants to merge 1 commit intodocker:mainfrom
Nikky000:fix/docker-auth-issue-39

Conversation

@Nikky000
Copy link

@Nikky000 Nikky000 commented Feb 3, 2026

Fixes #39

Problem

Users were unable to pull custom Docker images from private registries (e.g., ghcr.io) when using the MCP registry. The error encountered was:

pulling docker image ghcr.io/my-image: Error response from daemon: error from registry: denied

Even though users were authenticated locally and could run docker pull manually, the MCP registry code could not access their Docker credentials.

Root Cause

Docker pull commands executed via exec.Command were not inheriting environment variables from the host system. Docker relies on environment variables (PATH, HOME, etc.) to locate authentication credentials stored in ~/.docker/config.json.

Solution

Added environment variable inheritance to docker pull commands in two locations:

  1. internal/mcp/client.go - Modified the Start() method to use os.Environ() when pulling images
  2. cmd/build/main.go - Updated pullCommunityImage() to use the existing buildDockerEnv() helper
    This allows Docker to access host authentication credentials when pulling from private registries.

Changes

  • Added os import to internal/mcp/client.go
  • Modified Docker pull command in client.Start() to inherit environment variables
  • Updated pullCommunityImage() to use buildDockerEnv() for consistency

Testing

  • ✅ Project builds successfully: go build ./...
  • ✅ All tests pass: go test ./...
  • ✅ Minimal, focused changes: 2 files modified (5 insertions, 1 deletion)

Backward Compatibility

This change maintains full backward compatibility. Public images continue to work as before, while private images now work as expected when users are authenticated.

Fixes docker#39

- Added environment variable inheritance to docker pull commands
- Updated internal/mcp/client.go to use os.Environ()
- Updated cmd/build/main.go to use buildDockerEnv()

This allows docker pull to access host authentication credentials
when pulling images from private registries like ghcr.io
@Nikky000 Nikky000 requested a review from a team as a code owner February 3, 2026 07:18
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.

Unable to use Custom Image Name

2 participants