最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

google cloud platform - docker push to Artifact Registry returns error 400 - Stack Overflow

programmeradmin0浏览0评论

I am trying to push a docker image to Artifact Registry however I get error status 400 Bad Request:

code: "UNAUTHORIZED"
message: "not authenticated: No valid credential was supplied"

I assume this means that my authentication credentials for Google Artifact Registry are either missing or incorrect.

I am working from the owner account and should have correct credentials to push to the repository. What I've done so far:

  1. logged in with gcloud auth login successfully
  2. set gcloud auth configure-docker me-west1-docker.pkg.dev which is reflected in .docker/config.json file (seen below)
  3. added Artifact Registry Administrator and Artifact Registry Writer permission to my account (owner)
  4. attempted different authentication alternatives inlcuding (1) configured Docker authentication with gcloud auth configure-docker and (2) followed Configure authentication to Artifact Registry for Docker using the access token authentication method after which I still was unable to push to Artifact Registry

Here is my .docker/config.json file

{
    "auths": {
        "/": {},
        ";: {},
        "me-west1-docker.pkg.dev": {}
    },
    "credsStore": "desktop",
    "credHelpers": {
        "asia.gcr.io": "gcloud",
        "eu.gcr.io": "gcloud",
        "gcr.io": "gcloud",
        "marketplace.gcr.io": "gcloud",
        "me-west1-docker.pkg.dev": "gcloud",
        "staging-k8s.gcr.io": "gcloud",
        "us.gcr.io": "gcloud"
    },
    "currentContext": "desktop-linux",
    "plugins": {
        "-x-cli-hints": {
            "enabled": "true"
        }
    },
    "features": {
        "hooks": "true"
    }
}%                                      

Aside from that, I'm not sure how to proceed to add authentication on the client side.

I am trying to push a docker image to Artifact Registry however I get error status 400 Bad Request:

code: "UNAUTHORIZED"
message: "not authenticated: No valid credential was supplied"

I assume this means that my authentication credentials for Google Artifact Registry are either missing or incorrect.

I am working from the owner account and should have correct credentials to push to the repository. What I've done so far:

  1. logged in with gcloud auth login successfully
  2. set gcloud auth configure-docker me-west1-docker.pkg.dev which is reflected in .docker/config.json file (seen below)
  3. added Artifact Registry Administrator and Artifact Registry Writer permission to my account (owner)
  4. attempted different authentication alternatives inlcuding (1) configured Docker authentication with gcloud auth configure-docker and (2) followed Configure authentication to Artifact Registry for Docker using the access token authentication method after which I still was unable to push to Artifact Registry

Here is my .docker/config.json file

{
    "auths": {
        "https://index.docker.io/v1/": {},
        "https://index.docker.io/v1/refresh-token": {},
        "me-west1-docker.pkg.dev": {}
    },
    "credsStore": "desktop",
    "credHelpers": {
        "asia.gcr.io": "gcloud",
        "eu.gcr.io": "gcloud",
        "gcr.io": "gcloud",
        "marketplace.gcr.io": "gcloud",
        "me-west1-docker.pkg.dev": "gcloud",
        "staging-k8s.gcr.io": "gcloud",
        "us.gcr.io": "gcloud"
    },
    "currentContext": "desktop-linux",
    "plugins": {
        "-x-cli-hints": {
            "enabled": "true"
        }
    },
    "features": {
        "hooks": "true"
    }
}%                                      

Aside from that, I'm not sure how to proceed to add authentication on the client side.

Share Improve this question edited Feb 4 at 9:41 noor soreti asked Feb 3 at 16:13 noor soretinoor soreti 416 bronze badges 7
  • Please don't describe what you did but show what you did by including specific commands, the output that resulted and any errors. #1 gcloud CLI credential helper and #4 access token are alternatives. Is auth being persisted to config.json? – DazWilkin Commented Feb 3 at 19:29
  • Did you make sure to set your application default credentials for the Docker credential helper? You can do this by running the command gcloud auth login. – HerPat Commented Feb 3 at 22:36
  • @DazWilkin, I've edited my question to reflect your recommendations. I've also included my config.json file. – noor soreti Commented Feb 4 at 9:46
  • @HerPat, yes, already run that command – noor soreti Commented Feb 4 at 9:46
  • Have you tried running sudo gcloud auth login? If you use sudo with Docker, Docker will look for credentials in the root directory. If you didn't use sudo for the authentication login, it won't find the credentials there. – HerPat Commented Feb 4 at 13:37
 |  Show 2 more comments

1 Answer 1

Reset to default 0

I think I found the issue. It seems there may be conflicting settings in your config.json file.

Based from this documentation:

When Docker connects to a registry, it checks first for a credential helper that is associated with the host. So if your config.json includes Artifact Registry settings in both the credHelpers and auths sections, the settings in the auths section are ignored.

If you already have a credential helper configured for a registry in the credHelpers section, you can attempt to simply remove the corresponding entry in the auths section for that registry. For example, you can modify it as follows and check if it works:

{
    "auths": {
        "https://index.docker.io/v1/": {},
        "https://index.docker.io/v1/refresh-token": {},
    },
    "credsStore": "desktop",
    "credHelpers": {
        "asia.gcr.io": "gcloud",
        "eu.gcr.io": "gcloud",
        "gcr.io": "gcloud",
        "marketplace.gcr.io": "gcloud",
        "me-west1-docker.pkg.dev": "gcloud",
        "staging-k8s.gcr.io": "gcloud",
        "us.gcr.io": "gcloud"
    },

}%  

Hope this helps.

发布评论

评论列表(0)

  1. 暂无评论