Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honour DOCKER_CONFIG location for jib credentials #27460

Closed
njlaw opened this issue Aug 23, 2022 · 4 comments · Fixed by #27471
Closed

Honour DOCKER_CONFIG location for jib credentials #27460

njlaw opened this issue Aug 23, 2022 · 4 comments · Fixed by #27471
Labels
Milestone

Comments

@njlaw
Copy link

njlaw commented Aug 23, 2022

Description

Presently, jib looks in multiple locations for Docker registry credentials; however, the JibProcessor in Quarkus does not use the same order and only looks for ${user.home}/.docker/config.json. Ideally the Quarkus jib processor would use the same lookup order as the upstream jib tools.

Implementation ideas

Perhaps leveraging the DefaultCredentialRetrievers from the upstream project would make the most sense? I'm happy to attempt a pull request, but I'm not particularly familiar with the Quarkus coding style or project in general.

@njlaw njlaw added the kind/enhancement New feature or request label Aug 23, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 23, 2022

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Aug 24, 2022

This is not true, see this.

Are you seeing an issue where this does not work?

@njlaw
Copy link
Author

njlaw commented Aug 24, 2022

This is not true, see this.

Are you seeing an issue where this does not work?

If I'm reading it correctly, the logic in that function uses the supplied username and password if present; otherwise, it adds the credential helpers and the default Docker config.json file to the credential search path. However, it does not take into account the DOCKER_CONFIG environment variable if it is set.

The upstream DefaultCredentialRetrievers does and adds a fair number of other Docker config locations.

Here's some log output from an instance where the DOCKER_CONFIG environment variable is set, but it still uses the default path:

❯ export DOCKER_CONFIG=$(mktemp -d)
❯ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: njlaw
Password: 
WARNING! Your password will be stored unencrypted in /tmp/tmp.BrRabcWpIm/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
❯ mvn package  -Dquarkus.container-image.builder=jib -Dquarkus.jib.base-jvm-image=njlaw/some-private-image:11 -Dquarkus.container-image=njlaw/my-ptivate:latest -Dquarkus.container-image.build=true
...
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] The base image requires auth. Trying again for njlaw/some-private-image:11...
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] LogEvent [level=INFO, message=Docker config auths section defines credentials for registry-1.docker.io]
[INFO] [io.quarkus.container.image.jib.deployment.JibProcessor] LogEvent [level=LIFECYCLE, message=Using credentials from Docker config (/home/njlaw/.docker/config.json) for njlaw/some-private-image:11]

@geoand
Copy link
Contributor

geoand commented Aug 24, 2022

Thanks for the update.

Fair enough, we can add support for DOCKER_CONFIG as well.

geoand added a commit to geoand/quarkus that referenced this issue Aug 24, 2022
geoand added a commit to geoand/quarkus that referenced this issue Aug 24, 2022
gsmet added a commit that referenced this issue Aug 24, 2022
Add support for DOCKER_CONFIG env var when using Jib
@quarkus-bot quarkus-bot bot added this to the 2.13 - main milestone Aug 24, 2022
fercomunello pushed a commit to fercomunello/quarkus that referenced this issue Aug 31, 2022
@gsmet gsmet modified the milestones: 2.13 - main, 2.12.1.Final Sep 5, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Sep 5, 2022
Resolves: quarkusio#27460

Co-authored-by: George Gastaldi <[email protected]>
(cherry picked from commit 8b042db)
derlin added a commit to derlin/quarkus that referenced this issue Sep 16, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
derlin added a commit to derlin/quarkus that referenced this issue Oct 3, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
derlin added a commit to derlin/quarkus that referenced this issue Oct 4, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
derlin added a commit to derlin/quarkus that referenced this issue Oct 4, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
derlin added a commit to derlin/quarkus that referenced this issue Oct 4, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
gsmet pushed a commit to gsmet/quarkus that referenced this issue Oct 4, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.

(cherry picked from commit d5e2991)
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 16, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
igorregis pushed a commit to igorregis/quarkus that referenced this issue Oct 17, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
tmihalac pushed a commit to tmihalac/quarkus that referenced this issue Oct 27, 2022
Support for DOCKER_CONFIG has been added in quarkusio#27460. However, in jib,
the DOCKER_CONFIG should point to a directory containing a `config.json`,
while in the quarkus implementation it must point to the `config.json`
file itself. This is very confusing, especially since there is no
documentation.

This commit fixes the `JibProcessor`, so it behave exactly as described
in the jib documentation (see
https://github.com/GoogleContainerTools/jib/blob/master/jib-maven-plugin/README.md#authentication-methods).
That is, if `DOCKER_CONFIG` is set, it is expected to point to a folder
with a `config.json` file.

To keep backward compatibility, if `DOCKER_CONFIG` points to a file,
it will be left untouched.

See also `com.google.cloud.tools.jib.plugins.common.DefaultCredentialRetrievers.java`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants