Reputation: 1255
The first line of my .gitab-ci.yml
is the following:
image: gradle:5.0-jdk11
This image is 601mb and I am constantly having to pull it from docker hub on every invocation of my build.
Is there any way that the image can be stored on the project's docker repository in Gitlab? So that it is automatically placed there the first time the build is run and then retrieved from there on subsequent invocations of the build?
Upvotes: 3
Views: 1574
Reputation: 2541
If your Gitlab-runner already pulled the Docker-image, next time it needs it, it will pull the local image instead of downloading again the 601mB image. This is the default behaviour unless ou change as in https://docs.gitlab.com/runner/executors/docker.html#how-pull-policies-work
Keep in mind that f the image is removed from your gitlab-runner local images, it will have to pull it from scratch.
Upvotes: 1
Reputation: 1327784
That should be described by the page "Cache dependencies in GitLab CI/CD ", declaring your image as an artifact in the cache (defined by cache:paths
)
It’s sometimes confusing because the name artifact sounds like something that is only useful outside of the job, like for downloading a final image.
But artifacts are also available in between stages within a pipeline.
So if you build your application by downloading all the required modules, you might want to declare them as artifacts so that each subsequent stage can depend on them being there
Check also what your Docker runner cache directory includes.
If the issue persists, try and use a private registry, as in issue 41924:
image: my-private-registry:5000/my-ci-image:latest
Upvotes: 0