在此方面寻求帮助。 gitlab-ci是一个相当新的东西,尽管对Docker有一定的经验。
我为使docker executor成功构建而进行的所有尝试均以失败告终:
Running with gitlab-runner 11.1.0 (081978aa)
on my-runner 28d98f88
Using Docker executor with image docker:latest ...
Starting service docker:dind ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:9c33e070d450c33d0fda38016a1c454fcf296efc5af773d88fb5a5d17a99affc for docker:dind ...
Waiting for services to be up and running...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:8f769f924e650ea5f873bede823add9e33aa6c74a2b2dd8ccd54c2c9e97ce1d3 for docker:latest ...
Running on runner-28d98f88-project-9-concurrent-0 via gitlab.home...
Cloning repository...
Cloning into '/builds/root/gocryptme'...
fatal: unable to access 'https://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@cicd.home/root/gocryptme.git/': Could not resolve host: cicd.home
ERROR: Job failed: exit code 1
简而言之:
无法解析主机:cicd.home
尝试了到目前为止我遇到的所有建议。
我的.gitlab-ci.yml
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- release
- deploy
variables:
DOCKER_CI_IMAGE: cicd.home:4567/root/cidemo:cicd
before_script:
- whoami
- echo '10.11.0.130 cicd.home' >> /etc/hosts
build-image:
stage: build
tags:
- docker
script:
- docker build --pull -t $DOCKER_CI_IMAGE .
- docker push $DOCKER_CI_IMAGE
确保before_script:部分未产生预期的输出。
这是我的config.toml
concurrent = 1
check_interval = 0
[[runners]]
name = "my-runner"
url = "https://cicd.home/"
token = "28d98f88b621865293c49c7fadfc5d"
executor = "docker"
[runners.docker]
tls_verify = false
privileged = true
disable_cache = false
volumes = ["/cache", "/var/run/docker.sock:/var/run/docker.sock:rw"]
shm_size = 0
pull_policy = "if-not-present"
[runners.cache]
在我看来,添加到/ etc / hosts的过程在这里不起作用。