fix: erase the docker hub credential on registry:logout

Docker stores Docker Hub under the index server address rather than the hostname the user logged in with, and `docker logout` only erases the exact key it is given, so `registry:logout docker.io` reported success while leaving the credential in place. The server is now resolved to the key docker actually stores before the logout runs.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-19 18:56:46 -04:00
1 parent a4f791b85d
commit 2e3d144aca
5 files changed
+145 -6

No files matched your search

+5 -6
View File
@@ -32,9 +32,7 @@ func CommandLogin(appName string, server string, username string, password strin
return errors.New("Missing password argument")
}
if server == "hub.docker.com" || server == "docker.com" {
server = "docker.io"
}
server = normalizeRegistryServer(server)
buffer := bytes.Buffer{}
buffer.Write([]byte(password + "\n"))
@@ -92,9 +90,10 @@ func CommandLogout(appName string, server string) error {
return errors.New("Missing server argument")
}
if server == "hub.docker.com" || server == "docker.com" {
server = "docker.io"
}
// docker only erases the exact auths key it is given, and stores Docker Hub
// under the index server address rather than the hostname logged in with, so
// a logout for docker.io has to name that address to remove anything
server = dockerAuthKey(server)
env := map[string]string{}
if appName != "" {