How do I prevent the image from downloading every time the runner is run?

Hello,
The runner script is as follows:

deploy-portal:
  stage: deploy
  script:
    - cd /home/devops/
    - docker compose stop portal || true
    - docker compose rm -f portal || true
    - docker images -f "reference=*portal*" -q | xargs --no-run-if-empty docker image rm || true
    - docker compose build --no-cache portal || true
    - docker compose up -d portal
    - echo "y" | docker image prune

The image is downloaded every time the runner is run. How can I prevent this from happening? If I download the image with the docker pull command, will this problem be resolved?

Thank you.

You use

docker image rm
docker compose build --no-cache

I would not disable cache and only run docker image prune after build, so re-used image layers are not re-downloaded.

1 Like