Reputation: 5907
I am trying to push a Docker image into my container registry on Google Cloud platform. I am able to build my image successfully on my local machine. I tried the following command:
sudo docker push eu.gcr.io/$PROJECT_ID/$CONTAINER_NAME
I get a permission denied error:
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
I tried following the steps in the provided link, specifically the gcloud credential helper instructions. I also tried gcloud auth configure-docker
and gcloud auth login
, all to no avail. Regarding IAM permissions my personal email is listed as Owner and Storage Admin role. I also have manually set up a service account with Owner and Storage admin roles. My $GOOGLE_APPLICATION_CREDENTIALS
environment variable points to a json file extracted from this manually created service account. gcloud auth configure-docker
provides the following output:
WARNING: Your config file at [/home/awa5114/.docker/config.json] contains these credential helper entries:
{
"credHelpers": {
"gcr.io": "gcloud",
"us.gcr.io": "gcloud",
"eu.gcr.io": "gcloud",
"asia.gcr.io": "gcloud",
"staging-k8s.gcr.io": "gcloud",
"marketplace.gcr.io": "gcloud"
}
}
Adding credentials for all GCR repositories.
WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using.
gcloud credential helpers already registered correctly.
At this point, I don't understand why I am getting denied permission to push this image into the container registry. What can I try next?
Upvotes: 0
Views: 1354
Reputation: 1
running docker push without "sudo" resolved the same issue for me,
Running Docker commands without sudo requires that your user is added to the docker group. By default, Docker commands need root privileges, which is why they typically require sudo. Adding your user to the docker group grants the necessary permissions to run Docker commands without sudo
Upvotes: 0
Reputation: 5907
I finally got it to work. I did two things:
sudo
before the docker push
command....Upvotes: 1