You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docker login in 27.2.0 no longer overwrites existing config.json #5382
In Docker 27.1.2, running docker login multiple times causes the authentication information in ~/.docker/config.json to be updated with the latest successful execution.
In 27.2.0, the first successful authentication prevents config.json from being updated.
This is a breaking change because the existing expectation is that docker login always overwrites the authentication information.
Reproduce
docker login repository-a
docker login repository-b
docker push repository-b/image
The push will fail since the authentication information recorded is for repository-a.
changed the title [-]Docker cli 27.2.0 no longer overwrites existing config.json[/-][+]Docker login in 27.2.0 no longer overwrites existing config.json[/+]on Aug 30, 2024
$ docker login -u gitlab-ci-token -p $CI_JOB_TOKEN$CI_REGISTRY
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credential-stores
Login Succeeded
$ docker pull registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning:latest
latest: Pulling from gitlab-org/security-products/analyzers/container-scanning
e4fff0779e6d: Pulling fs layer
,,,
,,,
Digest: sha256:84c7ee8800ce979ef5482d5ca21086f05fbf50d3a477f8194e4b5e87233a5c24
Status: Downloaded newer image for registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning:latest
registry.gitlab.com/gitlab-org/security-products/analyzers/container-scanning:latest
$ if [ -n"$CS_DEPLOY_USERNAME" ] && [ -n"$CS_DEPLOY_PASSWORD" ];then# collapsed multi-line command
Login Succeeded
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credential-stores
The push refers to repository [registry.gitlab.com/security-products/container-scanning]
5f70bf18a086: Preparing
11c61dfd316c: Preparing
...
...
5f70bf18a086: Layer already exists
b70d9e93136f: Layer already exists
...
...
errors:
denied: requested access to the resource is denied
unauthorized: authentication required
Unfortunately the second login call is shown as "collapsed", but IIUC, the reproducer is effectively;
The problem looks to be that 27.2 is not converting the given registry to its hostname, and instead preserves the path (repository name), therefore storing each under a different key;
Re: #5378, I'm fairly certain it's a separate thing, because as I wrote there even in v27.1.2 if you only have credentials for https://index.docker.io/v1/ and do a pull from registry-1.docker.io, the pull is unauthenticated.
FYI @thiago-gitlab, running docker login [registry address] with the repository name/image included in the repo (such as docker login -u <USERNAME> index.docker.io/repository/name) is undocumented behavior – we're fixing this for now, but no guarantees about the future unless we settle on explicitly supporting it. In general it would be safer to not include the repo name when running docker login.
Activity
[-]Docker cli 27.2.0 no longer overwrites existing config.json[/-][+]Docker login in 27.2.0 no longer overwrites existing config.json[/+]thiago-gitlab commentedon Aug 30, 2024
A workaround is to downgrade to
27.1.2. Another workaround is to delete theconfig.jsonbefore authenticating for a second time. ExamplethaJeztah commentedon Aug 30, 2024
Thanks for reporting!
From that linked ticket;
Unfortunately the second login call is shown as "collapsed", but IIUC, the reproducer is effectively;
The problem looks to be that 27.2 is not converting the given registry to its hostname, and instead preserves the path (repository name), therefore storing each under a different key;
doing the same with 27.1;
thaJeztah commentedon Aug 30, 2024
cc @laurazard PTAL - looks like somewhere we're missing a call to
ConvertToHostnamecli/cli/config/credentials/file_store.go
Line 95 in 6273e65
(Wondering if this is actually the underlying issue related to #5378, and not the hostname that's used 🤔 )
laurazard commentedon Aug 30, 2024
Re: #5378, I'm fairly certain it's a separate thing, because as I wrote there even in v27.1.2 if you only have credentials for
https://index.docker.io/v1/and do a pull fromregistry-1.docker.io, the pull is unauthenticated.I see where this issue was introduced though.
laurazard commentedon Aug 30, 2024
FYI @thiago-gitlab, running
docker login [registry address]with the repository name/image included in the repo (such asdocker login -u <USERNAME> index.docker.io/repository/name) is undocumented behavior – we're fixing this for now, but no guarantees about the future unless we settle on explicitly supporting it. In general it would be safer to not include the repo name when runningdocker login.thiago-gitlab commentedon Aug 30, 2024
Thank you for letting me know, @laurazard. We'll fix that on our scripts and any user documentation.
And also thanks everyone for the amazingly quick response and fix. 🚀 🎉