Gitlab CI推送到docker-registry失败

时间:2020-07-02 07:19:47

标签: docker gitlab gitlab-ci gitlab-ci-runner docker-registry

我有GitLab服务器和一个单独的docker-registry。我用testuser创建了一个testpassword

我的.gitlab-ci.yml

image: docker:latest
services:
  - docker:18.09.7-dind
    
variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2
    # See https://github.com/docker-library/docker/pull/166
  DOCKER_TLS_CERTDIR: ""
  REGISTRY: myregistry:5000/golang-test

stages:
  - build
 # - test
before_script:
  - docker login -u testuser -p testpassword  myregistry:5000

build_project:
    stage: build
    tags:
      - docker-ci
    script:
      - docker ps
      - docker build -t $REGISTRY .
      - docker push $REGISTRY

CI管道运行时,出现以下错误。

警告!通过CLI使用--password是不安全的。采用 --password-stdin。来自守护程序的错误响应:获取https:// myregistry:5000 / v2 /:拨打tcp:lookup worker1 192.168.123.456:53:没有这样的主机错误:作业失败:退出代码1

concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "docker-ci"
  url = "https://gitlab.sample.com:8000/"
  token = "89MfxRTby83ny3eTkTf2"
  tls-ca-file = "/etc/gitlab-runner/certs/gitlab.sample.com.crt"
  executor = "docker"
  pre_build_script = "export DOCKER_HOST=tcp://docker:2375"
  [runners.custom_build_dir]
  [runners.cache]
    [runners.cache.s3]
    [runners.cache.gcs]
  [runners.docker]
    tls_verify = false
    image = "ubuntu:18.04"
    privileged = true
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

这是在here建议的修改之后。

我可以使用docker-registry从运行gitlab的服务器成功登录我的docker login -u testuser -p testpassword https://myregistry:5000refered

uwe-plonus评论之后,我添加了以下部分,但仍然是相同的错误。

before_script:
  - echo "192.168.10.219  worker1" >> /etc/hosts
  - docker login -u testuser -p testpassword  myregistry:5000

0 个答案:

没有答案