gradle-docker-plugin: DockerBuildImage fails to pull public repo images if registryUsername registryPassword are present
I have the exact same issue as: #275 which was closed for some reason.
I have docker gradle file that has the following closure.
docker{
registryCredentials {
username = System.env.DOCKER_USERNAME
password = System.env.DOCKER_PASSWORD
}
}
task buildOfficialCorrettoDockerImage(type: DockerBuildImage, dependsOn: [buildDockerFolder]) {
inputDir = new File(project.buildDir, "docker-temp")
tags = correttoBuildTags
dockerFile = new File(new File(project.buildDir, "docker-temp"), "DockerfileAL")
}
When running this the following error:
Could not build image: Get https://registry-1.docker.io/v2/library/amazonlinux/manifests/2: unauthorized: incorrect username or password
When I run without the credentials closure, it builds fine, but then obviously I cannot push to the registry because we do not have the credentials.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (6 by maintainers)
@cdancy Yes, that will work now with the proposed DSL.
@bmuschko well I don’t want to change the existing credentials just point at a different registry for this specific task which I believe your PR addresses.
@cdancy I already made those improvements in https://github.com/bmuschko/gradle-docker-plugin/pull/879 as it will also make https://github.com/bmuschko/gradle-docker-plugin/pull/865 easier to implement.
@cdancy I assume you are just asking about the DSL-aspect of it? And the use case is only the one if you wanted to assign different credentials for two different custom tasks? If that’s the case then it’s easy to achieve. I’d suggest opening a new issue.
BTW: You do not need to create a new instance of
DockerRegistryCredentials. You can just change the values of the existing propertyregistryCredentials. So this should work:Will try asap, not at computer for today!