轉載引用:https://www.cnblogs.com/floodwater/p/10138265.html
1、安裝docker
2、安裝gitlab-ce
1、安裝docker
下載地址:
https://docs.docker.com/docker-for-mac/install/
在國內做開發必須談網絡問題,安裝好docker之后,建議使用國內的docker鏡像源,我用的是aliyun的。
- 首先你得有aliyun的賬號:
- 然后進去到https://dev.aliyun.com/search.html
- 如果你登錄了,進入到上面的頁面,點擊上面頁面的【管理中心】
- 然后點擊【鏡像加速器】就可以按照提示配置了
2、安裝gitlab-ce
使用下面的命令安裝gitlab-ce
sudo docker run --detach \ --hostname mygitlab.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
上面的參數說明:
hostname按照自己的需要改
volume的冒號前面為物理機器上的實際目錄,需提前建好,然后改為正確路徑。冒號后面為掛載點,不要改
publish的三個端口映射自己看情況來,一般自己網內使用,光一個80就好了,443和22都需要額外配置數字證書什么的
然后打開瀏覽器訪問:
localhost
或者
mygitlab.com
這個時候會要求你修改root賬戶的密碼,輸入2次密碼確定就可以了。注意這個root賬戶是gitlab的賬戶不是你mac系統的root賬戶,不要搞錯了。
到這里,在macos中搭建gitlab系統就算完成了。
問題記錄:
安裝gitlab 的時候報錯:
docker: Error response from daemon: Mounts denied:
The paths /srv/gitlab/logs and /srv/gitlab/config and /srv/gitlab/data
are not shared from OS X and are not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
沒看懂官方的解決辦法,用以下方式替代了/srv目錄
sudo docker run --detach \ --hostname mygitlab.com \ --publish 443:443 --publish 80:80 --publish 22:22 \ --name gitlab \ --restart always \ --volume ~/gitlab/config:/etc/gitlab \ --volume ~/gitlab/logs:/var/log/gitlab \ --volume ~/gitlab/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
再次執行安裝的時候會報錯容器已存在:
docker: Error response from daemon: Conflict. The container name "/gitlab" is already in use by container "6a2ab4021a505b3c1522773a7870d46468d5624f54b46d0071ea3da52ecb449e". You have to remove (or rename) that container to be able to reuse that name.
需要先刪除容器再操作,然后安裝就完成了。
docker rm 6a2ab4021a505b3c1522773a7870d46468d5624f54b46d0071ea3da52ecb449e