以下三部分内容都是来自:【Gitlab文档】
注意,Gitlab至少需要2G内存来跑
一、docker方式:域名
1 2 3 4 5 6 7 8 9 10
| $ sudo docker pull gitlab/gitlab-ce:latest $ sudo docker run --detach \ --hostname gitlab.example.com \ --publish 443:443 --publish 80:80 --publish 22: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
|
二、docker方式:IP
假如公网IP: 192.168.0.200
1 2 3 4 5 6 7 8 9 10 11
| $ sudo docker run --detach \ --hostname gitlab.example.com \ --publish 192.168.0.200:443:443 \ --publish 192.168.0.200:80:80 \ --publish 192.168.0.200:22: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
|
运行时出现错误(可能要注释掉指定22端口):
1 2 3 4 5
| docker: Error response from daemon: driver failed programming external connectivity on endpoint gitlab (b24b2757ac70353b9ea1f24ebdbaa9244fe614444619e604c3d29dc3d17ddce6): Error starting userland proxy: listen tcp 192.168.0.200:22: bind: address already in use.
|
非Docker安装Gitlab并不会和SSH的端口22产生冲突
三、docker-compose方式(推荐)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| web: image: 'gitlab/gitlab-ce:latest' restart: always hostname: 'gitlab.example.com' environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://gitlab.example.com' # 这里可以填 gitlab.rb 的配置信息 gitlab_rails['time_zone'] = 'Asia/Shanghai' ports: - '80:80' volumes: - '/srv/gitlab/config:/etc/gitlab' - '/srv/gitlab/logs:/var/log/gitlab' - '/srv/gitlab/data:/var/opt/gitlab'
|
经过验证,Gitlab可以跑起来。
四、汉化版
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| version: '3' services: gitlab: image: 'twang2218/gitlab-ce-zh:9.4' restart: unless-stopped hostname: 'gitlab.example.com' environment: TZ: 'Asia/Shanghai' GITLAB_OMNIBUS_CONFIG: | external_url 'http://gitlab.example.com' gitlab_rails['time_zone'] = 'Asia/Shanghai' ports: - '80:9999' volumes: - /home/fantj/app/docker/compose/gitlab/config:/etc/gitlab - /home/fantj/app/docker/compose/gitlab/data:/var/opt/gitlab - /home/fantj/app/docker/compose/gitlab/logs:/var/log/gitlab
|