- [root@sannian data-ci]# docker search GitLab-runner
- [root@sannian data-ci]# docker pull GitLab/GitLab-runner
- [root@sannian data-ci]# docker run -d -v /data-ci/:/data-ci/ --restart=always --name GitLab-runner GitLab/GitLab-runner
然后注册:
- [root@sannian data-ci]# docker exec -it 80ac801e633b GitLab-runner register
- Runtime platform arch=amd64 os=Linux pid=16 revision=cf91d5e1 version=11.4.2
- Running in system-mode.
- Please enter the GitLab-ci coordinator URL (e.g. https://gitlab.com/):
- http://47.99.145.156:9999/
- Please enter the GitLab-ci token for this runner:
- Ah-B41xF53-R4M6bamrE
- Please enter the GitLab-ci description for this runner:
- [80ac801e633b]:
- Please enter the GitLab-ci tags for this runner (comma separated):
- my-erp
- Registering runner... succeeded runner=Ah-B41xF
- Please enter the executor: docker, docker-SSH, parallels, VirtualBox, docker-SSH+machine, shell, SSH, docker+machine, kubernetes:
- shell
- Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
这后就是 GitLab 报错
然后就是发现用户是 --user=GitLab-runner
- [root@sannian data-ci]# ps -ef | grep GitLab-runner
- root 31028 30984 0 10:30 ? 00:00:00 /usr/bin/dumb-init /entrypoint run --user=GitLab-runner --working-directory=/home/GitLab-runner
- root 31091 31028 0 10:30 ? 00:00:00 GitLab-runner run --user=GitLab-runner --working-directory=/home/GitLab-runner
- root 31155 31017 0 10:30 pts/2 00:00:00 grep --color=auto GitLab-runner
为了解决这个问题
进入容器
- [root@sannian data-ci]# docker exec -it 80ac801e633b /bin/bash
- root@80ac801e633b:/# su GitLab-runner
- GitLab-runner@80ac801e633b:/$ SSH-keygen
- Generating public/private rsa key pair.
- Enter file in which to save the key (/home/GitLab-runner/.SSH/id_rsa):
- Enter passphrase (empty for no passphrase):
- Enter same passphrase again:
- Your identification has been saved in /home/GitLab-runner/.SSH/id_rsa.
- Your public key has been saved in /home/GitLab-runner/.SSH/id_rsa.pub.
- The key fingerprint is:
- SHA256:SzbhlkF6U+eHCSqToSnHzrivfbLEl+zJLk0G3KUsI3M GitLab-runner@80ac801e633b
- The key's randomart image is:
- +---[RSA 2048]----+
| . . o . |
- | . o =.o + o |
- | ..=o=o* + . |
- | o*E += = . |
- | .+o+ S |
- | o .o= o |
| . o++ . |
- | +o+o. |
- | ..+*= |
- +----[SHA256]-----+
- GitLab-runner@80ac801e633b:/$ VIM /home/GitLab-runner/.SSH/id_rsa.pub
把密复制到远程主机上. 光这个还不行, 还要在容器里测试一下
- GitLab-runner@80ac801e633b:/$ scp -r /data-ci/eatjoys-front.sh root@47.99.89.247://data-ci/eatjoys-front.sh
- The authenticity of host '47.99.89.247 (47.99.89.247)' can't be established.
- ECDSA key fingerprint is SHA256:a6E2UXjP1qIZLmHAS6LAfyeUjsidFhTCZxefKC4cDGk.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added '47.99.89.247' (ECDSA) to the list of known hosts.
- eatjoys-front.sh
第一次, 一定要输入一下 yes 才会通过, 然后看 GitLab 上
通过了, 这样就可以继续下一步 写脚本咯~!
来源: https://yq.aliyun.com/articles/672280