Roshan  Chamlagain
Roshan Chamlagain

Reputation: 305

How do I get Docker registry username and password in gitlab.com?

I want to login to Docker Registry in Gitlab.com using Ansible play, but how do I get Docker Registry username and password in gitlab?

Is it same as gitlab.com username and password?

Upvotes: 5

Views: 8789

Answers (2)

DevThiman
DevThiman

Reputation: 1138

Though there is an accepted answer using personal access token, we can do this by using a Deploy token as well.

Main difference between Personal Access Token and Deploy Token are to use personal access token, you need to have a Gitlab account (username & pwd) to use with personal access token and it can be used to authenticate with GitLab API as well.

In otherhand Deploy tokens allow you to download (git clone) or push and pull packages and container registry images of a project without having a user and a password. Deploy tokens cannot be used with the GitLab API.

To create a deploy token go to

Project settings >> Repository >> Deploy tokens

Then you can give token name, expiration date, username and scopes for the token.

enter image description here

You can refer more about Gitlab tokens here.

Upvotes: 1

King Chung Huang
King Chung Huang

Reputation: 5644

Registry credentials in GitLab are the same as the repositories they belong to. So, you can use your GitLab.com username and password.

That said, you should probably create a personal access token with only read_registry permissions to use with Ansible, instead of literally using your account credentials, to limit what Ansible can do. And, you can revoke the token if it leaks.

Documentation: Personal access tokens

Upvotes: 6

Related Questions