docker-maven-plugin: Multi-platform buildx: unauthorized for fetching metadata for the base image

Description

Using the plugin to run multi-platform builds via buildx fails to get the meta-data of base images, if the base image is located at a registry which needs authentication. The registry is configured in settings.xml.

Info

  • docker-maven-plugin version : 0.40.1
  • Maven version (mvn -v) :
Maven home: /opt/homebrew/Cellar/maven/3.8.5/libexec
Java version: 11.0.15, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@11/11.0.14.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_AT, platform encoding: UTF-8
OS name: "mac os x", version: "12.4", arch: "aarch64", family: "mac"
  • Docker version : 20.10.13
  • If it’s a bug, how to reproduce : Build a multi-platform image with a base image from a private registry.

Sample output:

[INFO] DOCKER> #4 [linux/amd64 internal] load metadata for myregistry.example.com/openjdk:8-jre-slim
[INFO] DOCKER> #4 ERROR: pulling from host myregistry.example.com failed with status code [manifests 8-jre-slim]: 401 Unauthorized
[INFO] DOCKER> 
[INFO] DOCKER> #5 [linux/arm64 internal] load metadata for myregistry.example.com/openjdk:8-jre-slim
[INFO] DOCKER> #5 ERROR: pulling from host myregistry.example.com failed with status code [manifests 8-jre-slim]: 401 Unauthorized

Using docker buildx directly on the command-line works.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I can provide a PR with this two fixes to the project today or tomorrow

Hi @rohanKanojia, for my purpose 0.43.2 seems to work as expected. the --config parameter is no longer present, and therefor a local docker login is sufficient to let the plugin build multi-arch images and push them to a registry with authentication.

thanks you very much.

I’m facing a similar problem. In samples/multi-architecture when building the project :

docker --config /<long path>/docker-maven-plugin/samples/multi-architecture/target/docker/hello/multiarch/0.43-SNAPSHOT/docker buildx create --driver docker-container --name maven
[INFO] DOCKER> unknown flag: --driver
[INFO] DOCKER> See 'docker --help'.

If I remove the --confg /path all works fine. So I modified this line: https://github.com/fabric8io/docker-maven-plugin/blob/043a5698b1408e3a1a95a2e84dfed08da2ec5b24/src/main/java/io/fabric8/maven/docker/service/BuildXService.java#L66

to:

        List<String> buildX = Arrays.asList("docker",  "buildx");

And the samples/multi-architecture is working fine. Is this --config needed? To me, it looks like the bouldX service is mixing docket config and buildx config.

Final note, my versions

 docker --version
Docker version 23.0.5, build bc4487a59e
docker buildx version
github.com/docker/buildx v0.10.4 c513d34049e499c53468deac6c4267ee72948f02