当我尝试在Docker中为Gitlab EE安装Runner时出现问题

时间:2018-10-31 15:54:14

标签: docker gitlab gitlab-ci gitlab-ci-runner

Gitlab:11.4.3-ee(dce6f33) Debian 9

我尝试在自己的gitlab服务器中安装Runner with Docker

root@gitlab:~# curl -sSL https://get.docker.com/ | sh
# Executing docker install script, commit: 36b78b2
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sh -c curl -fsSL "https://download.docker.com/linux/debian/gpg" | apt-key add -qq - >/dev/null
Warning: apt-key output should not be parsed (stdout is not a terminal)
+ sh -c echo "deb [arch=amd64] https://download.docker.com/linux/debian stretch edge" > /etc/apt/sources.list.d/docker.list
+ [ debian = debian ]
+ [ stretch = wheezy ]
+ sh -c apt-get update -qq >/dev/null
+ sh -c apt-get install -y -qq --no-install-recommends docker-ce >/dev/null
+ sh -c docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:23:18 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:22:21 2018
  OS/Arch:          linux/amd64
  Experimental:     false
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.

将配置卷安装到gitlab-runner

root@gitlab:~# docker run -d --name gitlab-runner --restart always \
>   -v /srv/gitlab-runner/config:/etc/gitlab-runner \
>   -v /var/run/docker.sock:/var/run/docker.sock \
>   gitlab/gitlab-runner:latest
Unable to find image 'gitlab/gitlab-runner:latest' locally
latest: Pulling from gitlab/gitlab-runner
18d680d61657: Pull complete
0addb6fece63: Pull complete
78e58219b215: Pull complete
eb6959a66df2: Pull complete
a468a6515b4f: Pull complete
40651eb3dddb: Pull complete
ed4168d5c959: Pull complete
6119c208b565: Pull complete
dc48c135c379: Pull complete
Digest: sha256:51314e4f978572ede9e3140d21af09ab94c8c3cba94d97e35c8efa4119f0b415
Status: Downloaded newer image for gitlab/gitlab-runner:latest
ec396bbdb74448cfb790bdf0480ebbc20b05998e209f1e5a6b5a9ce51739c6cd

尝试根据Gitlab Manual注册跑步者时出现第一个错误

root@gitlab:~# docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register
docker: Error response from daemon: Conflict. The container name "/gitlab-runner" is already in use by container "ec396bbdb74448cfb790bdf0480ebbc20b05998e209f1e5a6b5a9ce51739c6cd". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help’.

我正在寻找有关此问题的任何信息,并在Stackoverflow中获取一些数据,但是不起作用。

docker rm -f gitlab-runner

root@gitlab:~# docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register
docker: Error response from daemon: Conflict. The container name "/gitlab-runner" is already in use by container "ec396bbdb74448cfb790bdf0480ebbc20b05998e209f1e5a6b5a9ce51739c6cd". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
root@gitlab:~# docker rm -f gitlab-runner
gitlab-runner
root@gitlab:~# docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner --name gitlab-runner gitlab/gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=8 revision=cf91d5e1 version=11.4.2
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.mydomain.com
Please enter the gitlab-ci token for this runner:
fGXLEzM9GwyrKRbBXuxz
Please enter the gitlab-ci description for this runner:
[d70537116aed]: dockercentral
Please enter the gitlab-ci tags for this runner (comma separated):
dockercentral
ERROR: Registering runner... failed                 runner=fGXLEzM9 status=couldn't execute POST against https://gitlab.mydomain.com/api/v4/runners: Post https://gitlab.mydoamia.com/api/v4/runners: dial tcp 195.XX.XX.15:443: i/o timeout
PANIC: Failed to register this runner. Perhaps you are having network problems

尝试使用elink从外部机器访问内部地址

通过浏览器

https://gitlab.castris.com/api/v4/runners获得

的json
[{"id":2,"description":"Runner-Group","ip_address":"195.154.58.15","active":true,"is_shared":false,"name":"gitlab-runner","online":true,"status":"online"}]

从控制台https://gitlab.castris.com/api/v4/runners

链接https://gitlab.castris.com/api/v4/runners获取->

{"message": "401 Unauthorized"}

0 个答案:

没有答案