Post

Docker를 이용하여 GitLab 설치

1. GitLab Docker images 다운로드

gitlab-docker-images

1
[root@localhost ~]# docker pull gitlab/gitlab-ce:latest

2. Pull 이미지 확인

1
[root@localhost ~]# docker images

3. GitLab Images 실행

도커 포트 매핑은 호스트 포트:컨테이너 포트로 이루어진다. 즉, 웹에서 접근시 서버 주소:80으로 접속할 수 있고 SSH로 GitLab 접속시 서버 주소와 ssh 22 포트로 접속할 수 있다.

  • 포트 번호 설명
    • 22: SSH
    • 80: HTTP
    • 443: HTTPS
1
[root@localhost ~]# docker run --detach --hostname 127.0.0.1 --publish 8929:80 --publish 2224:22 --name gitlab --restart always --volume /srv/gitlab/config:/etc/gitlab --volume /srv/gitlab/logs:/var/log/gitlab --volume /srv/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest

4. GitLab Configuration 설정

포트를 변경하였기 때문에 내부 설정도 변경한다.

1) gitlab 컨테이너 접속

1
[root@localhost ~]# docker exec -it gitlab /bin/bash

2) nano 에디터로 gitlab.rb 파일 수정

Ctrl + o로 저장하고 Enter를 누른 후 Ctrl + x로 나노 에디터를 나온다.

1
root@127:/# nano /etc/gitlab/gitlab.rb
1
2
external_url 'http://127.0.0.1:8929'
gitlab_rails['gitlab_shell_ssh_port'] = 2222

3) 설정 적용

1
root@127:/# gitlab-ctl reconfigure

4) Docker 재시작

1
[root@localhost ~]# docker restart gitlab

5. 접속

  • http://127.0.0.1:8929

6. 에러 종류

1) gitlab 이름의 container가 있음

  • 에러 메시지
1
2
docker: Error response from daemon: Conflict. The container name "/gitlab" is already in use by container "7cc5f742bee7b7fd1abfb7bda954e02fd82f8cd87eeddb327e891a2e46446e98". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
  • 해결 방법: gitlab 이름의 컨테이너가 실행 중인지 확인

2) 22번 포트 사용중

  • 에러 메시지
1
docker: Error response from daemon: driver failed programming external connectivity on endpoint gitlab (4e9c2e29d9490c79ed30a40a5d1593ace6584c488000b2185e63990f11f3b504): Error starting userland proxy: listen tcp4 0.0.0.0:22: bind: address already in use.
  • 해결 방법: 포트 변경

[출처 및 참고]

This post is licensed under CC BY 4.0 by the author.