Skip to content

docker buildx policy eval --fields fails to authenticate against dhi.io and requests an anonymous token #3984

Description

@danez

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

docker buildx policy eval successfully parses a Docker Hardened Images (DHI) image reference when using --print only. However, as soon as any --fields option is specified, Buildx attempts to fetch an anonymous token from dhi.io instead of using the existing credentials from docker login dhi.io, resulting in a 401 Unauthorized.

The same image can be pulled successfully with docker pull, confirming that authentication is configured correctly.

The issue reproduces on both macOS and Linux.

The same failure occurs with every tested field, including:

  • image.user
  • image.env
  • image.labels
  • image.workingDir
  • image.volumes
  • image.hasProvenance
  • image.provenance
  • image.signatures

Error:

ERROR: failed to authorize: failed to fetch anonymous token:
unexpected status from GET request to
https://dhi.io/token?scope=repository%3Anode%3Apull&service=registry.docker.io:
401 Unauthorized

Expected behaviour

When resolving image metadata for --fields, docker buildx policy eval should reuse the registry credentials configured via docker login dhi.io, just as docker pull does, and successfully resolve the requested image fields.

Actual behaviour

As soon as any --fields option is requested, docker buildx policy eval attempts to authenticate anonymously against dhi.io instead of using the configured credentials, causing metadata resolution to fail with 401 Unauthorized.

Buildx version

0.36.0

Docker info

Client:
 Version:    29.6.2
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  agent: Docker AI Agent Runner (Docker Inc.)
    Version:  v1.111.0
    Path:     /Users/username/.docker/cli-plugins/docker-agent
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.27.0
    Path:     /Users/username/.docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.35.0-desktop.2
    Path:     /Users/username/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.3.1
    Path:     /Users/username/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.47
    Path:     /Users/username/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.4.3
    Path:     /Users/username/.docker/cli-plugins/docker-desktop
  dhi: CLI for managing Docker Hardened Images (Docker Inc.)
    Version:  v0.0.7
    Path:     /Users/username/.docker/cli-plugins/docker-dhi
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /Users/username/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /Users/username/.docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.43.3
    Path:     /Users/username/.docker/cli-plugins/docker-mcp
  model: Docker Model Runner (Docker Inc.)
    Version:  v1.2.6
    Path:     /Users/username/.docker/cli-plugins/docker-model
  offload: Docker Offload (Docker Inc.)
    Version:  v0.6.9
    Path:     /Users/username/.docker/cli-plugins/docker-offload
  pass: Docker Pass Secrets Manager Plugin (beta) (Docker Inc.)
    Version:  v0.2.0
    Path:     /Users/username/.docker/cli-plugins/docker-pass
  sandbox: "docker sandbox" is deprecated, use Docker Sandboxes instead (Docker Inc.)
    Version:  v0.13.0
    Path:     /Users/username/.docker/cli-plugins/docker-sandbox
  scout: Docker Scout (Docker Inc.)
    Version:  v1.24.0
    Path:     /Users/username/.docker/cli-plugins/docker-scout

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 31
 Server Version: 29.6.2
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Discovered Devices:
  cdi: docker.com/gpu=webgpu
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e53c7c1516c3b2bff98eb76f1f4117477e6f4e66
 runc version: v1.3.6-0-g491b69ba
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 14
 Total Memory: 7.749GiB
 Name: docker-desktop
 ID: 7aaabe80-b097-46b7-b152-a8bbe4e2a211
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/username/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables

Builders list

NAME/NODE                       DRIVER/ENDPOINT     STATUS    BUILDKIT   PLATFORMS
default                         docker
 \_ default                      \_ default         running   v0.31.2    linux/amd64 (+2), linux/arm64, linux/ppc64le, linux/s390x, (2 more)
desktop-linux                   docker
 \_ desktop-linux                \_ desktop-linux   running   v0.31.2    linux/amd64 (+2), linux/arm64, linux/ppc64le, linux/s390x, (2 more)

Configuration

IMAGE='dhi.io/node:24.18.0-alpine3.24@sha256:34f3ad0f7a2997d136106a0959a21293cf3b8bbc8496aaf78aa2798eff01b011'

docker login dhi.io
docker pull "$IMAGE"

# Works
docker buildx policy eval \
  --print \
  "docker-image://${IMAGE}"

# Fails
docker buildx policy eval \
  --print \
  --fields image.user \
  "docker-image://${IMAGE}"

Build logs


Additional info

I also tested with 0.36.0 to make sure it is not the old version bundled in docker desktop

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions