Skip to content

Image building does not validate that image registry host matches publish registry URL  #29281

Open
@liyuan-rey

Description

@liyuan-rey

hello,

Envronment:
System: Windows 10 Home x64 21H2
JDK: 11.0.13
Spring Boot: 2.6.2
Docker Desktop 4.3.2 (WSL 2 based)

We built a private docker repositories with Sonatype Nexus at http://172.2.3.5:9000/.

Try build image for a simple Spring REST WebApp.

build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version '2.6.2'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
}

...

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
}

bootBuildImage {
    imageName = "mycompany/mygroup/myproject:1.0.1"
    publish = true
    docker {
        publishRegistry {
            url = "http://172.2.3.5:9000/"
            username = "user"
            password = "pass"
        }
    }
}

Run .\gradlew.bat bootBuildImage, got outputs like:

...
> Task :bootBuildImage
- Building image 'docker.io/mycompany/mygroup/myproject:1.0.1'

 > Pulling builder image 'docker.io/paketobuildpacks/builder:base' ......
...
 > Pulling run image 'docker.io/paketobuildpacks/run:base-cnb' ......
...
 > Running creator
...

- Successfully built image 'docker.io/mycompany/mygroup/myproject:1.0.1'

- > Pushing image 'docker.io/mycompany/mygroup/myproject:1.0.1' .......

...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootBuildImage'.
> Error response received when pushing image: unauthorized: incorrect username or password

...

Notice that the red lines always output 'docker.io/' even if 'docker.publishRegistry.url' is specified, so I guess the task might try to push the image to ‘docker.io’ instead of '172.2.3.5:9000', and it fails.

Please let me know if there is any misunderstanding, thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions