Search code examples
dockergitlabgitlab-cidocker-in-docker

Cannot pull images using authenticated user in GitlabCI


I'm trying to mitigate the DockerHub pull limit by logging in to a DockerHub account in my gitlab-runner. I'm not using methods like Gitlab's Dependency proxy because I would have to edit hundreds of files. I decided to log in to Docker in gitlab-runner.

.gitlab-ci.yml:

image: docker

services:
  - docker:dind

stages:
  - base

docker-build:
  stage: base
  tags:
    - experimental
  script:
    - docker build -t grex:alpine_${CI_PIPELINE_ID} ./alpine
    - docker info

The alpine folder contains a Dockerfile containing just FROM alpine. The config.toml of the gitlab-runner has the line pre_build_script = "docker login -u grex -p <password>"

The docker info line states that my user is logged in. I followed all of the options from the docs but to no avail. After each pipeline run, I checked the current rate limit for my user and it remained unchanged, leaving me to infer the pipeline made an unauthenticated docker pull. Any help is appreciated!


Solution

  • After some experimentation, it seems Gitlab caches images and that resulted in the number of pulled images to not change.