Skip to main content

Fixing "denied: requested access to the resource is denied"

Recently at work I had to prepare a Docker image for a new service we wanted to deploy.
Writing the Dockerfile, building the Docker image, everything went smoothly until I was greeted with this error message upon pushing the finished image.

denied: requested access to the resource is denied

At first, I didn't know what went wrong:

  • Did I tag the image wrong?
  • Am I not allowed to have an extra slash in the tag name?
  • Am I not correctly signed in?
  • Do I not have the correct access rights to the repository?

After checking that I was indeed signed in correctly, slashes are allowed within tags and I had the correct access rights I had no other option than to search the internet for an answer.

Turns out, it's a problem that many people have stumbled over already. Here's a link to the original GitLab bug report. That's where I found the solution.


The solution is to head over to your GitLab user settings and create a new Personal Access Token (PAT).
Now there are two scopes that need to be set for the PAT to work with the registry:

  1. api
  2. read_registry

Once you have create your PAT, make sure to copy the token before leaving the page, because your token is not going to be displayed again.

Now all that's left is to sign out of Docker on your CLI using

docker logout <registry_hostname:port>

and signing back in using the PAT you just created as the password:

docker login <registry_hostname:port> -u <your_username> --password-stdin

If everything went correctly, you should now be able to push your Docker image to GitLab without running into the problem.

Published on January 17, 2021
Last modified on March 15, 2021

Did you like what you read? Feel free to share! Make sure to follow me on Twitter to stay in the loop.