【发布时间】:2020-12-25 05:54:55
【问题描述】:
我在本地运行 GitLab 和 Gitlab-Runner docker 实例。执行 Spring Boot 和 Maven 项目管道时,出现以下错误。
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/root/starter-springboot-pipeline/.git/
fatal: unable to access 'http://localhost/root/starter-springboot-pipeline.git/': Failed to connect to localhost port 80: Connection refused
Uploading artifacts for failed job
00:07
ERROR: Job failed: exit code 1
不确定上述错误中的 localhost 是指 GitLab 容器还是 Runner 容器。它应该引用 gitlab 容器而不是 localhost 吗?
以下是我使用的命令和配置。
启动 GitLab 服务器:
docker run -itd --network=gitlab-network --hostname localhost \
--publish 443:443 --publish 80:80 --publish 22:22 \
--name gitlab --restart always --volume config:/etc/gitlab \
--volume logs:/var/log/gitlab \
--volume data:/var/opt/gitlab \
gitlab/gitlab-ee:12.10.14-ee.0
启动 GitLab Runner
docker run -d --name gitlab-runner --restart always \
-v ~/gitlab/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:v12.10.3
创建了网络“gitlab-network”并将两个容器都添加到其中。
docker network connect gitlab-network gitlab
docker network connect gitlab-network gitlab-runner
按照以下方式注册跑步者:
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://gitlab
Please enter the gitlab-ci token for this runner:
XxXXxXXXxxXXXXXX
Please enter the gitlab-ci description for this runner:
[49ad685039ad]: runner14
Please enter the gitlab-ci tags for this runner (comma separated):
docker
Registering runner... succeeded runner=EkWnb63h
Please enter the executor: docker-ssh, parallels, shell, virtualbox, docker+machine, kubernetes, custom, docker, ssh, docker-ssh+machine:
docker
Please enter the default Docker image (e.g. ruby:2.6):
alpine:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
下面是 gitlab-ci.yml
image: maven:3.3-jdk-8
stages:
- test
test_job:
stage: test
script:
- pwd
- mvn clean
- mvn compile
- mvn test
tags:
- docker
我刚刚开始研究 GitLab 和 docker,在通过大量研究解决了一些问题后,我能够设置它们并运行管道。但我被这个问题困住了。
【问题讨论】:
标签: docker gitlab gitlab-ci gitlab-ci-runner