config.toml中[runners.docker]部分对docker机器的用例有什么用?

时间:2017-12-14 13:30:44

标签: gitlab-ci docker-machine gitlab-ci-runner vsphere toml

阅读documentation on autoscaling当使用docker + machine作为执行者时,我无法确定[runner.docker]部分的作用:

  [runners.docker]
    image = "ruby:2.1"               # The default image used for builds is 'ruby:2.1'

executors documentation中说:

  

docker + machine:与docker一样,但使用自动缩放的docker机器 -   这需要[runners.docker]和[runners.machine]

的存在

我得知我必须定义这个[runners.docker]部分才能使用[runners.machine]部分,但这个[runners.docker]的目的是什么? 我找不到如何配置它,因为我不明白为什么要使用它。

我们的gitlab-runner在vSphere VM上运行,并配置为使用docker + machine executor和MachineDriver使用vmwarevsphere进行扩展。一切都很好,但我想完全理解配置文件。

这是我们用“runners.docker”审查的“带星星审查”的config.toml文件我无法理解(请注意,编写它的人离开公司,所以我不能问他):

[[runners]]
  name = "gitlab-runner"
  limit = 6
  output_limit = 102400
  url = "http://gitlab.**************.lan"
  token = "*******************"
  executor = "docker+machine"

  [runners.docker]
    tls_verify = false
    image = "docker:latest"
    dns = ["*.*.*.*"]
    privileged = true
    disable_cache = false
    volumes = ["/etc/localtime:/etc/localtime:ro", "/var/run/docker.sock:/var/run/docker.sock", "/etc/docker/certs.d:/etc/docker/certs.d", "/cache:/cache", "/builds:/builds"]
    cache_dir = "cache"
    shm_size = 0

  [runners.cache]
    Type = "s3"
    ServerAddress = "*.*.*.*"
    AccessKey = "*****************"
    SecretKey = "*****************"
    BucketName = "runner"
    Insecure = true

  [runners.machine]
    IdleCount = 4
    MaxBuilds = 10
    IdleTime = 3600
    MachineDriver = "vmwarevsphere"
    MachineName = "gitlab-runner-pool-1-%s"
    MachineOptions = ["vmwarevsphere-username=************", "vmwarevsphere-password=*****************", "vmwarevsphere-vcenter=*.*.*.*", "vmwarevsphere-datastore=*********", "vmwarevsphere-memory-size=3096", "vmwarevsphere-disk-size=40960", "vmwarevsphere-cpu-count=3", "vmwarevsphere-network=*****************", "vmwarevsphere-datacenter=**************", "vmwarevsphere-hostsystem=*******************", "engine-storage-driver=overlay2", "engine-insecure-registry=**************", "engine-insecure-registry=*******************"]
    OffPeakPeriods = ["* * 0-8,21-23 * * mon-fri *", "* * * * * sat,sun *"]
    OffPeakTimezone = "Local"
    OffPeakIdleCount = 1
    OffPeakIdleTime = 600

1 个答案:

答案 0 :(得分:1)

[runners.machine]部分定义了如何启动和配置您的跑步机,然后[runners.docker]部分定义如何配置跑步者机。

Docker-machine本身只执行以下操作(因为您可以阅读here):

  

“Docker Machine是一个工具,可让您在虚拟主机上安装Docker Engine,并使用docker-machine命令管理主机。”

所以这对Gitlab运行器没有任何作用,你仍然需要在那之后配置运行器以及[runners.docker]部分发挥作用的地方,因为运行器需要知道要使用的默认映像和要安装的卷等