docker에 gitlab-runner 설치

이재원·2022년 10월 31일
0

1 도커에 git-lab-runner 실행

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:v14.7.0

2 도커 shell로 gitlab-runner install 실행

docker exec -it gitlab-runner gitlab-runner install

3 도커 shell로 gitlab-runner register 실행

  • 아래 명령어 순차적으로 수행
C:\Windows\system32>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:v14.7.0
Unable to find image 'gitlab/gitlab-runner:v14.7.0' locally
v14.7.0: Pulling from gitlab/gitlab-runner
ea362f368469: Pull complete
52673b55c58a: Pull complete
5971d00b9354: Pull complete
Digest: sha256:b6c4834ec360e993ae88ce70469f284338346b4dc9f889922a8ab25cd46aaae2
Status: Downloaded newer image for gitlab/gitlab-runner:v14.7.0
d4045b4f1d9f9366e3154d49a472d94a6d19932172def05f7cd909c5417ee163

C:\Windows\system32>docker exec -it gitlab-runner gitlab-runner install

C:\Windows\system32>docker exec -it gitlab-runner gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=26 revision=98daeee0 version=14.7.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
https://gitlab.twolinecode.com/

Enter the registration token:
fsfsjfskjfslkjfslkfjsklfdjsldfk(gitlab 프로젝트 사이트에 있는 ci/cd 토큰 붙여넣기)

Enter a description for the runner:
[d4045b4f1d9f]: jw-lee

Enter tags for the runner (comma-separated):  (태그추가 인데 empty 값으로 엔터)
Registering runner... succeeded                     runner=GR134894\

Enter an executor: docker, shell, docker-ssh+machine, kubernetes, custom, docker-ssh, parallels, ssh, virtualbox, docker+machine:docker

Enter the default Docker image (for example, 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!

C:\Windows\system32>docker exec -it gitlab-runner gitlab-runner start
Runtime platform                                    arch=amd64 os=linux pid=72 revision=98daeee0 version=14.7.0

4 등록한 모든 runner 제거

gitlab-runner unregister --all-runners

5 docker shell 접속

cmd창에서 docker exec -it gitlab-runner bash

6 docker build시 Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running? 에러발생 해결방법

  • gitlab-runner server가 설치된 shell에 접속
  • etc/gitlab-runner/config.toml 파일을 vim으로 열어 "privileged=false" 값을 "privileged=true"로 변경

0개의 댓글