使用gitlab CI构建docker镜像并推送到自签名的https nexus repo

时间:2017-10-15 13:36:28

标签: docker gitlab self-signed

我有一个gitlab CI设置,我想构建和推送docker图像,第一个问题是我的nexus repo不是https。 实际的错误信息是:

  

来自守护程序的错误响应:获取http://some.host:port/v2/:http:   服务器向HTTPS客户端提供HTTP响应

要构建泊坞窗图片,我们使用.gitlab-ci.yml图片,我找不到在image: docker:latest services: - docker:dind before_script: - docker info - docker login -u USER -p PASSWORD some.host:port stages: - build build-image: stage: build script: - docker build -t some.host:port/image:alpine . - docker push some.host:port/image:alpine only: - master when: manual

中添加我们的主机作为不安全注册表的方法

所以自我签署了我的nexus存储库,希望它能解决,但它也没有用,并提供以下错误信息:

  

来自守护程序的错误响应:获取https://some.host:port/v2/:x509:   由未知权威机构签署的证书

这是我目前的CI设置:

popAlert

那么是否有一个简单的解决方案或现有的docker镜像我可以配置不安全的注册表可能是一些docker magic with command line我真的需要创建一个自己的图像来解决这个问题吗?

2 个答案:

答案 0 :(得分:5)

您可以使用不同的命令启动docker dind。有关详细信息,请参阅以下网址

https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#setting-a-command-for-the-service。因此,您需要更新.gitlab.ci.yml

image: docker:latest

services:
- name: docker:dind
  command: [ "--insecure-registry=some.host:port" ]

before_script:
  - docker info
  - docker login -u USER -p PASSWORD some.host:port

stages:
  - build

build-image:
  stage: build
  script:
    - docker build -t some.host:port/image:alpine .
    - docker push some.host:port/image:alpine
  only:
    - master
  when: manual

然后你可以使用不安全的http注册表

答案 1 :(得分:1)

在语法上略有修改的情况下为我工作,Command需要数组。

services:
- name: docker:dind
  command: ["--insecure-registry=some.host:port"]