Gitlab Runner每次执行都会重复拉取docker镜像非常慢

要先明白runner里镜像拉取的策略,是有配置参数的,官方文档:

https://docs.gitlab.com/runner/configuration/advanced-configuration.html

文中提到策略有3种参数:The image pull policy: never, if-not-present or always (default).

进一步查看策略解释文档:

https://docs.gitlab.com/runner/executors/docker.html#how-pull-policies-work

很明显,never是从不从远端拉镜像,只用本地。if-not-present 是优先本地,然后是从网络拉取镜像。always 是从远端拉取镜像。

解决办法:配置先从本地拉取。

vi /etc/gitlab-runner/config.toml
添加:    pull_policy = "if-not-present"

[[runners]]
  name = "cloud-runner"
  url = "https://www.gitlab.com/"
  token = "117942j2j3j234"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    pull_policy = "if-not-present"
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]
京ICP备11047313号-19 术语 百科 技巧 彩虹岛电子书