docker安裝流程
-
獲取gitlab(社區版) --已有鏡像時,可跳過此步
docker pull gitlab/gitlab-ce:latest -
創建本地卷用於保存gitlab數據 (持久化gitlab數據,否則重啓會造成數據丟失)
e:\dockerdata\config \logs \data
-
運行
docker run --detach --hostname xxxx.com --publish 443:443 --publish 80:80 --publish 22:22 --name gitlab --restart always --volume E:/dockerdata/gitlab/config:/etc/gitlab --volume E:/dockerdata/gitlab/logs:/var/log/gitlab --volume E:/dockerdata/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest- hostname : 安裝服務的ip,xxxx.com爲host映射
- publish 443:443 https的端口,左邊是宿主機對外端口,右邊是容器內端口
- publish 8080:8080 http訪問的端口。左邊是宿主機對外端口,右邊是容器內端口
- publish 5000:22 ssh方式下載對應的端口,左邊是宿主機對外端口,右邊是容器內端口
注意,要用http方式連接,publish 8080:8080 前後兩個端口需要一樣
-
查看初始密碼
docker exec -it [容器id] bash
cat /etc/gitlab/initial_root_password --
- 瀏覽器訪問
瀏覽器打開:xxxx.com 默認用戶名:root 默認賬戶名是root,密碼存放在配置文件 /etc/gitlab/initial_root_password 需要手動進入容器查看 docker exec -it gitlab /bin/bash/gitlab/ cat initial_root_password //查看文件密碼