Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab runner pulls image for every job

Tags:

gitlab

dock

I have a gitlab runner using docker as the executor. My problem is, it pulls the image I have defined for every job, which takes more time to finish the pipeline

enter image description here

How can I cache the image and add a pull policy for the job or the runner ? Anyone please?

like image 911
Jananath Banuka Avatar asked Jul 22 '20 21:07

Jananath Banuka


People also ask

What is the default Docker image for GitLab runner?

To use GitLab Runner with Docker you need to register a runner that uses the Docker executor. The registered runner uses the ruby:2.6 Docker image and runs two services, postgres:latest and mysql:latest , both of which are accessible during the build process.

How do I pull an image from GitLab?

Use images from the Container Registry To download and run a container image hosted in the GitLab Container Registry: Copy the link to your container image: Go to your project or group's Packages & Registries > Container Registry and find the image you want. Next to the image name, select Copy.


2 Answers

The pull policy by default for a docker executor is "Always". You can use "if-not-present" pull policy to make sure it is only pulled when it is not available locally.

Read the documentation for option here and how the policies work here

like image 115
Tarun Khosla Avatar answered Sep 26 '22 13:09

Tarun Khosla


Check if the latest GitLab 13.8 (January 2021) can help.

Configure multiple image pull policies for Docker executor

When your CI jobs are retrieving a container image from a container registry, a lost network connection can result in hours of lost development time and can negatively impact time-sensitive product deployments.

To address this resiliency problem, the GitLab Runner Docker executor now supports the use of multiple values for the pull_policy configuration, which is defined in the GitLab Runner config.toml file.

You can use these values, or stacked image pull policies, to configure combinations of pull policies and mitigate the impact caused by lost connectivity.

For example, if you configure pull_policy =[always, if-not-present], the pull policy will always pull the image.
However, if the target container registry is not available, the GitLab Runner Docker executor will fall back and use the if-not-present policy, which means a local copy of the image will be used for that pipeline job.

https://about.gitlab.com/images/13_8/runner-docker-pull-policy.png -- Configure multiple image pull policies for Docker executor

See Documentation and Issue.

like image 41
VonC Avatar answered Sep 24 '22 13:09

VonC