Search code examples
dockergitlabcicd

Docker failed to pull image with specify policies


I am building up my CI flow with docker and Gitlab.

I've registered docker-runner in my server and made sure the image I built is in the server by "cmd: docker images" but I keep seeing the error message below.

According to the gitlab-ci.yml, when I push the code, the CI flow will be triggered and build my code base "test" in the container.

Thanks for your help! enter image description here

This is my .gitlab-ci.yml

stages: 
    - build

build-code:
  stage: build
  script:
    - docker-compose up build

And docker-compose.yml:

version: '3'

services:
  build:
  volumes:
    - .:/test
  command: /bin/bash -c "\
    cd /test/cpp && \
    mkdir -p build && \
    cd build && \
    cmake .. && \
    make -j12"

update: seems no effect enter image description here


Solution

  • You might need to change your pull_policy to if-not-present in your config.toml. Otherwise it will try to pull the image every time, even if it already exists.

    [[runners]]
      (...)
      executor = "docker"
      [runners.docker]
        (...)
        pull_policy = "if-not-present"
    
    

    Gitlab Doc