簡體   English   中英

將 gitlab-runner 從 docker 注冊到 gitlab

[英]register gitlab-runner to gitlab from docker

我是 docker 的新手。 我使用以下命令運行 gitlab ce 容器:

docker run --detach --hostname localhost --publish 443:443 --publish 80:80 --name gitlab --restart always gitlab/gitlab-ce:latest

這個容器很好用

我使用以下命令運行 gitlab-runner 容器:

docker run -d --name gitlab-runner --restart always gitlab/gitlab-runner:latest

我的問題是當我想注冊 gitlab-runner 時,跑步者問我:

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):

我回答這個問題: http://localhost:80/但它給了我錯誤:

ERROR: Registering runner... failed                 runner=K8trLPJx status=couldn't execute POST against http://localhost:80/api/v4/runners: Post http://localhost:80/api/v4/runners: dial tcp 127.0.0.1:80: connect: connection refused
PANIC: Failed to register this runner. Perhaps you are having network problems

2 個容器在我的電腦上運行 windows 10

我不想在我的電腦上運行 gitlab-runner localy,我希望 docker 運行它

問題是您缺少兩個容器之間的網絡。 您可以像這樣手動創建它:

docker network create gitlab-network

並讓您的容器使用以下命令加入它:

docker network connect gitlab-network gitlab
docker network connect gitlab-network gitlab-runner

then you can pass as gitlab-ci coordinator URL just gitlab , as the name of the container is the is the dns on which the containers are reachable on docker networks.

另一個更優雅的解決方案是使用docker-compose來管理容器和網絡。 像這樣的東西,我沒有測試過:

version: '3.3'

services:
  gitlab:
    image: gitlab/gitlab-ce:latest
    networks:
      - gitlab-network
    ports:
      - 80:80
      - 443:443
    

  gitlab-runner:
    image: gitlab/gitlab-runner:latest
    networks:
      - gitlab-network

networks:
  gitlab-network:
I just tried the first method, but it doesn't work.

PS H:\> docker network connect gitlab-network 92a8e1ad4d08
PS H:\>
PS H:\> docker network connect gitlab-network b1a400049385
PS H:\>
PS H:\>
PS H:\> docker exec -it gitlab-runner gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=107 revision=5316d4ac version=14.6.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
http://localhost
Enter the registration token:
zorPvFMYsR8xZsK4Skos
Enter a description for the runner:
[b1a400049385]: git runner test
Enter tags for the runner (comma-separated):
gitlab-ci,docker-ci
ERROR: Registering runner... failed                 runner=zorPvFMY status=couldn't execute POST against http://localhost/api/v4/runners: Post http://localhost/api/v4/runners: dial tcp 127.0.0.1:80: connect: connection refused
PANIC: Failed to register the runner. You may be having network problems.
PS H:\>
PS H:\> docker exec -it gitlab-runner gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=129 revision=5316d4ac version=14.6.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
http://localhost:80
Enter the registration token:
zorPvFMYsR8xZsK4Skos
Enter a description for the runner:
[b1a400049385]: git runner test
Enter tags for the runner (comma-separated):
gitlab-ci,docker-ci
ERROR: Registering runner... failed                 runner=zorPvFMY status=couldn't execute POST against http://localhost:80/api/v4/runners: Post http://localhost:80/api/v4/runners: dial tcp 127.0.0.1:80: connect: connection refused
PANIC: Failed to register the runner. You may be having network problems.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM