3

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?

vab2048
  • 1,065
  • 8
  • 21

2 Answers2

1

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.

djuarezg
  • 2,307
  • 2
  • 20
  • 34
0

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • What would be the best way to get the `gradle:5.0-jdk11` image from dockerhub into my project's private registry? – vab2048 Dec 18 '18 at 15:06
  • @vab2048 useing docker pull (from docker hub), and then docker push (to your private registry), after tagging your pulled image (as in https://stackoverflow.com/a/28349540/6309) – VonC Dec 18 '18 at 15:29