How to use authentication with a docker registry, and have gitlab access the repository with .gitlab-ci.yml

  devops

Log into your private registry manually from the shell:

docker login registry.research.example.com:5000 --username my_username --password my_password

# ex:
docker login https://registry.research.example.com --username abcd --password password

then grab this file:

cat ~/.docker/config.json

# the entire JSON string, and add it in Gitlab under your Group -> Settings -> CI/CD -> Variables, and add new variable:
# Key: DOCKER_AUTH_CONFIG
# Value: the JSON string from above.

Ex:

{
        "auths": {
                "registry.research.example.com": {
                        "auth": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX="
                }
        },
        "HttpHeaders": {
                "User-Agent": "Docker-Client/19.03.1 (linux)"
        }
}