Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build docker images with gitlab CI and push to self signed https nexus repo

I have a gitlab CI setup where i would like build and push docker images, the first problem was that my nexus repo wasn't https. The actual error message was this:

Error response from daemon: Get http://some.host:port/v2/: http: server gave HTTP response to HTTPS client

To build docker images we use docker:latest image, and i can't find the way to add our host as insecure registry in .gitlab-ci.yml

So a self signed my nexus repository in hope it will solve, but it's not worked either and giver the following error message:

Error response from daemon: Get https://some.host:port/v2/: x509: certificate signed by unknown authority

this is my current CI setup:

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

So is there a simple solution or an existing docker image where i can configure insecure registries may be some docker magic with command line i really need to create an own image to solve this?

like image 788
Syngularity Avatar asked Oct 15 '17 13:10

Syngularity


2 Answers

You can launch docker dind with different command. See below url for more details

https://docs.gitlab.com/ce/ci/docker/using_docker_images.html#setting-a-command-for-the-service. So you need to update your .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

Then you can use a insecure http registry

like image 57
Tarun Lalwani Avatar answered Sep 29 '22 22:09

Tarun Lalwani


Worked for me with slight modification in syntax, Command expects array.

services:
- name: docker:dind
  command: ["--insecure-registry=some.host:port"]
like image 21
Saurabh Srivastava Avatar answered Sep 29 '22 23:09

Saurabh Srivastava