Herpes Free Engineer
Herpes Free Engineer

Reputation: 2672

How to avoid multiple pulls of the same image?

The following .gitlab-ci.ylm file contains two stages and a request for an image:

image: alpine

stages:
  - test
  - build

random-job-1:
  stage: build
  script: echo "I am Job-1"

random-job-2:
  stage: test
  script: echo "I am Job-2"

The pipeline shows that the image is pulled per stage, hence twice for this pipeline.

Is there any way to avoid multiple pulls of the specified image by pulling an image per pipeline:

Upvotes: 2

Views: 893

Answers (1)

sytech
sytech

Reputation: 41119

When you use a self-hosted runner with a docker based executor, images cached on the host are reused according to the pull policy configuration. By default, images are cached and reused so long as there is not a newer image available than the image that is already cached.

On gitlab.com, shred runners run on autoscaling instances that are short-lived, so there won't be any images cached on it. Because any given job can be picked up by any number of potentially thousands of machines, caching doesn't make sense in the context of gitlab.com -- the images are always pulled for each job

Upvotes: 4

Related Questions