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
How can I cache the image and add a pull policy
for the job
or the runner
? Anyone please?
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.
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.
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
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 Runnerconfig.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 willalways
pull the image.
However, if the target container registry is not available, the GitLab Runner Docker executor will fall back and use theif-not-present
policy, which means a local copy of the image will be used for that pipeline job.See Documentation and Issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With