Skip to content

GitLab cheat sheet

A collection of useful GitLab commands.

Login to GitLab registry

When working with Docker images from private repositories, you need to log in to be able to pull them.

First create a personal access token with read_api permissions:

https://gitlab.com/-/profile/personal_access_tokens

Store the access token in a secure place, since this is basically a password. For this example, we store it in a file .token. Just to be on the safe side, make this file readable by yourself only:

chmod 0600 .token

Use the token to login to the registry (replace $GITLAB_USERNAME by your GitLab username):

cat .token | docker login -u "$GITLAB_USERNAME" --password-stdin registry.gitlab.com

You should see a message "Login Succeeded".

You can now pull any Docker image that you have access to.