简体   繁体   中英

Failed to authorize when pushing docker image to GCR

I got stuck when pushing my docker image to Google Container Registry. There is always this error message:

failed to authorize: failed to fetch anonymous token: unexpected status: 401 Unauthorized

I did run gcloud auth login with my company email (user account not service account)

I did run gcloud auth configure-docker

Tools version:

docker: 20.10.21

gcloud: 410.0.0

Everything is okay with my company's Mac Mini and my personal Linux Desktop but my Macbook. (the same account and steps to setup)

Does anyone know about this problem? Please give me an instruction. Thank you in advance.

Create a service account: That requires permission and roles to write to the Cloud Storage bucket containing the container registry. Granting the service account either the project editor role or write access to the bucket (via ACL) solves the issue. The latter should be preferable since the account doesn't receive wider permissions than it needs.

To push the images to GCR follow the below steps:

1.Add a registry

2.Check the permissions

3.Choose the authentication method

4.Tag

5.Tag the local image with the registry name

6.Push tagged image to gcr

Refer to the link Pushing and Pulling images for more information.

If you encounter any issues with Docker on Mac, try below steps:

  • Run the docker-machine restart default command in the Mac terminal to restart the Docker daemon.

  • Ensure that "Securely store docker logins in macOS keychain" is not enabled in Docker's Preferences menu.

  • Ensure that you're running the most recent Docker version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM