2016-07-21 149 views
6

像我想創建一個基於多克Gitlab CI亞軍其拉泊塢窗圖像用於從私人碼頭工人註冊(V2)構建。我不能讓Gitlab亞軍從本地註冊表拉圖像,它會嘗試獲取來自/v1 API的東西。我收到以下錯誤消息:Gitlab CI不能拉從私人碼頭工人註冊表

ERROR: Build failed: Error while pulling image: Get http://registry:5000/v1/repositories/maven/images : dial tcp: lookup registry on 127.0.1.1:53: no such host

下面是一個使用docker-compose和Web瀏覽器的最小示例。

我有以下docker-compose.yml文件:

version: "2" 

services: 
    gitlab: 
    image: gitlab/gitlab-ce 
    ports: 
     - "22:22" 
     - "8080:80" 
    links: 
     - registry:registry 

    gitlab_runner: 
    image: gitlab/gitlab-runner 
    volumes: 
     - /var/run/docker.sock:/var/run/docker.sock 
    links: 
     - registry:registry 
     - gitlab:gitlab 

    registry: 
    image: registry:2 

第一Gitlab登錄後,我註冊了亞軍到Gitlab實例:

[email protected]:/# gitlab-runner register 
Running in system-mode.        

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci): 
http://192.168.61.237:8080/ci   
Please enter the gitlab-ci token for this runner: 
tE_1RKnwkfj2HfHCcrZW 
Please enter the gitlab-ci description for this runner: 
[130d08732613]: docker 
Please enter the gitlab-ci tags for this runner (comma separated): 

Registering runner... succeeded      runner=tE_1RKnw 
Please enter the executor: docker-ssh+machine, docker, docker-ssh, parallels, shell, ssh, virtualbox, docker+machine: 
docker 
Please enter the default Docker image (eg. ruby:2.1): 
maven:latest 
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

在這之後,我看到Gitlab亞軍我Gitlab實例:

Gitlab Runner in Gitlab instance

在此之後我把一個簡單的Maven圖像到我的新創建碼頭工人庫:

[email protected]:~/$ docker tag maven:3-jdk-7 172.19.0.2:5000/maven:3-jdk7 
[email protected]:~/$ docker push 172.19.0.2:5000/maven:3-jdk7 
The push refers to a repository [172.19.0.2:5000/maven] 
79ab7e0adb89: Pushed 
f831784a6a81: Pushed 
b5fc1e09eaa7: Pushed 
446c0d4b63e5: Pushed 
338cb8e0e9ed: Pushed 
d1c800db26c7: Pushed 
42755cf4ee95: Pushed 
3-jdk7: digest: sha256:135e7324ccfc7a360c7641ae20719b068f257647231d037960ae5c4ead0c3771 size: 1794 

(我從一個docker inspect命令的輸出172.19.0.2 IP地址)

此後,我在創建一個測試項目Gitlab並添加一個簡單的.gitlab-ci.yml文件:

image: registry:5000/maven:3-jdk-7 

stages: 
    - build 
    - test 
    - analyze 

maven_build: 
    stage: build 
    script: 
    - "mvn -version" 

和內部版本後Gitlab給在文章的開頭看到的錯誤。

如果我進入運行gitlab亞軍容器,我可以給定的URL下訪問註冊表:

[email protected]:~/$ docker exec -it comptest_gitlab_runner_1 bash 
[email protected]:/# curl http://registry:5000/v2/maven/tags/list 
{"name":"maven","tags":["3-jdk7"]} 
[email protected]:/# exit 
exit 
[email protected]:~/$ 

但錯誤還是一樣:

Gitlab Runner in Gitlab instance

你有任何想法如何強制gitlab跑步者使用私人註冊表的v2 api?

+0

你試過從澆道內拉的形象呢?也許與「外部」IP?那麼從主機拉圖像呢? – Martin

+0

@mgansler如果我輸入gitlab_runner映像('docker exec -it comptest_gitlab_runner_1 bash'),則沒有docker命令。但註冊表看到了,因爲我可以使用curl註冊表的HTTP API。 –

回答

0

你對Gitlab運行哪個版本的泊塢窗? 也爲V2註冊表,你必須明確地允許不安全的註冊表有一個命令行開關,或使用證書保證您的註冊表。

否則泊塢窗退回到V1註冊表如果它得到一個安全異常。

+0

碼頭版本是'1.11.2',詳細版本信息在這裏:http://pastebin.com/g9ma56ME 不安全的註冊表在主機操作系統中設置如下:'--insecure-registry registry:5000 '。我不知道gitlab runner如何啓動容器 - 它使用哪個docker二進制文件,在哪個文件中我應該在runner映像中設置不安全的註冊表等等。gitlab_runner圖像在路徑中沒有docker可執行文件,所以我不知道從哪裏開始。 –

相關問題