gradle-docker-plugin
gradle-docker-plugin copied to clipboard
Multiple registryCredentials can't be configured in the DockerExtension - must be configured in ~/.docker/config.json or at each task as a workaround
This is an enhancement request. At the moment you can configure in the DockerExtension only one credential set:
pluginManager.withPlugin("com.bmuschko.docker-remote-api") {
docker {
registryCredentials {
url = "https://${dockerRegistry}/v2/"
username = project.property("repository_username")
password = project.property("repository_password")
}
}
}
My build has some subprojects, those are using different registries to pull from and to push images to. It would be nice if you could configure the credentials for registry URL A and B in the extension and both are used where applicable.
Something like:
pluginManager.withPlugin("com.bmuschko.docker-remote-api") {
docker {
registryCredentials {
url = "https://${dockerRegistry}/v2/"
username = project.property("repository_username")
password = project.property("repository_password")
}
registryCredentials {
url = "https://${AnotherDockerRegistry}/v2/"
username = project.property("repository_username2")
password = project.property("repository_password2")
}
}
}
At the moment the only workaround is to either specify on each task who needs another registry the credentials block which is cumbersome to manage because I can't configure it on a central place or to use ´docker login ....´ on the command line because the plugin will fallback to use those credentials - but I would like to remove that workaround and be able to configure both registries (or even more) in the extension block.
I would recommend configuring the registry on a per-task level which will override the centrally-configured credentials. Configuration of the credentials through the extension is probably going to be a good chunk of work. I won't have time to work on that now, but feel free to propose a pull request on this.