How to Fix “ERROR [internal] load metadata for docker.io” Docker Credentials Issue on MacOS


12 views

The error message ERROR [internal] load metadata for docker.io/library/golang:1.20.1-alpine3.17 typically occurs when Docker cannot authenticate with Docker Hub to pull the required image. The key part of the error is error getting credentials - err: exit status 1, which indicates a credentials management problem.

On MacOS, this usually happens when:

  • The Docker credential helper isn't properly configured
  • There are permission issues with the keychain
  • The Docker daemon isn't running correctly
  • Network restrictions prevent access to Docker Hub

Before diving deeper, try these basic solutions:

# Restart Docker
open -a Docker

# Log out and back into Docker
docker logout
docker login

The most reliable solution is to reconfigure the credential helper:

# Remove existing credential configuration
rm ~/.docker/config.json

# Create new configuration with proper helper
echo '{"credsStore":"osxkeychain"}' > ~/.docker/config.json

# Verify the setup
docker-credential-osxkeychain list

If the credential helper still causes problems, you can store credentials directly (less secure):

# Store credentials in plaintext (not recommended for production)
echo '{"auths":{"https://index.docker.io/v1/":{"auth":"base64_encoded_creds"}}}' > ~/.docker/config.json

If the issue is network-related, try:

# Check DNS resolution
dig registry-1.docker.io

# Test direct connection
curl -v https://registry-1.docker.io/v2/

For more detailed error information:

DOCKER_BUILDKIT=0 docker build --no-cache --progress=plain .

After applying fixes, verify with:

docker pull golang:1.20.1-alpine3.17

When working with Docker-based Go projects (especially in blockchain development), you might encounter this credential-related error during the build phase. The core issue manifests when Docker can't properly authenticate with Docker Hub to pull the base image (golang:1.20.1-alpine3.17 in this case).

ERROR [internal] load metadata for docker.io/library/golang:1.20.1-alpine3.17
ERROR: failed to solve: error getting credentials - err: exit status 1

After debugging similar cases in multiple environments (MacOS, Linux, CI/CD pipelines), these are the most frequent culprits:

  • Docker Desktop credential helper misconfiguration
  • Corporate firewalls/proxies blocking Docker Hub access
  • Outdated Docker cache with expired credentials
  • Permission issues with credential store files

1. Reset Docker Credentials

First try logging out and back into Docker Hub:

docker logout
docker login

If you're behind a corporate proxy:

export HTTPS_PROXY=http://your.proxy:port
docker login

2. Verify Credential Helpers

Check your Docker config file (typically at ~/.docker/config.json):

cat ~/.docker/config.json

If you see "credsStore": "osxkeychain" (MacOS) or similar, try:

{
  "auths": {
    "https://index.docker.io/v1/": {}
  },
  "credsStore": "desktop"
}

3. Alternative: Use Explicit Credentials

For CI environments, you might need to pass credentials directly:

docker build \\
  --build-arg DOCKER_HUB_USER=your_username \\
  --build-arg DOCKER_HUB_PWD=your_password \\
  -t your_image .

And in your Dockerfile:

ARG DOCKER_HUB_USER
ARG DOCKER_HUB_PWD
RUN echo "$DOCKER_HUB_PWD" | docker login -u "$DOCKER_HUB_USER" --password-stdin

If the issue persists, try these diagnostic commands:

# Check Docker daemon logs
journalctl -u docker --no-pager -n 50

# Test direct image pull
docker pull golang:1.20.1-alpine3.17

# Verify network connectivity
curl -v https://registry-1.docker.io/v2/
  • Always pin your base images to specific versions (like you did with 1.20.1-alpine3.17)
  • Set up proper credential rotation policies
  • For production environments, consider mirroring Docker Hub images in a private registry
  • Use --pull flag in CI pipelines: docker build --pull ...

Remember that this error often surfaces when Docker's background authentication processes fail silently. The solutions range from simple credential refreshes to more complex network configuration adjustments depending on your environment.