How to push and pull docker images from Gitlab with access token

Viewed 2575

I am trying to push an image to a gitlab registry with two factor authentication. It gives me this error message:

unauthorized: HTTP Basic: Access denied\nYou must use a personal access token with 'api' scope for Git over HTTP

I tried to use this command to login but it still says access denied:

docker login https://registry.gitlab.com/my_registry -u my_user_name -p my_public_key

What am I doing wrong? How can I push and pull images with the public key?

1 Answers

Ok I found my error I was using my_public_key but I should have used a gitlab access token instead generated as the instructions in the link say.

So the correct command is :

docker login https://registry.gitlab.com/my_registry -u my_user_name -p my_gitlab_token

Or better yet for security purposes provide the password not in the command but when prompted after the command like this:

docker login https://registry.gitlab.com/my_registry -u my_user_name
Related