一. 安裝Docker CE (參考 官網指南)
1. 卸載老版本
sudo apt-get remove docker docker-engine docker.io
2. Update the apt
package index:
sudo apt-get update
3. Install packages to allow apt
to use a repository over HTTPS:
sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ software-properties-common
4. Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
, by searching for the last 8 characters of the fingerprint.
sudo apt-key fingerprint 0EBFCD88
pub 4096R/0EBFCD88 2017-02-22
Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid Docker Release (CE deb) <docker@docker.com>
sub 4096R/F273FCD8 2017-02-22
5. Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
To add the edge or test repository, add the word edge
or test
(or both) after the word stable
in the commands below.
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable"
b. armhf:
echo "deb [arch=armhf] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list
6. Update the apt
package index.
sudo apt-get update
7. Install the latest version of Docker CE:
sudo apt-get install docker-ce
8. Verify that Docker CE is installed correctly by running the hello-world
image:
x86_64:
sudo docker run hello-world
armhf:
sudo docker run armhf/hello-world
9. 卸載Docker (以后需要卸載的話,再來看看)
a. Uninstall the Docker CE package:
sudo apt-get purge docker-ce
b. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
sudo rm -rf /var/lib/docker
必須手動寫在其他的配置文件.
二. 安裝gitlab
1. 執行下面的命令,從 docker 的鏡像倉庫中下載 gitlab 社區版的鏡像
docker pull gitlab/gitlab-ce:latest
比較大,1G左右, 喝杯咖啡享受下人生
2. 容器運行gitlab
一定要root用戶運行($ su -), 否則git clone會要密碼, 切記,切記!
docker run --detach \ --hostname 192.168.1.6 \ --publish 8443:443 --publish 8080:80 --publish 2222:22 \ --name gitlab \ --restart always \ --volume /home/gitlab/config:/etc/gitlab \ --volume /home/gitlab/logs:/var/log/gitlab \ --volume /home/gitlab/data:/var/opt/gitlab \ docker.io/gitlab/gitlab-ce
等幾分鍾再登陸,:
http://192.168.1.6:8080 (對應自己的IP)
作者:小狐濡尾
鏈接:https://www.jianshu.com/p/05e3bb375f64
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。
作者:小狐濡尾
鏈接:https://www.jianshu.com/p/05e3bb375f64
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。
作者:小狐濡尾
鏈接:https://www.jianshu.com/p/05e3bb375f64
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。
參數說明:
--detach
: 設置容器后台運行--hostname
: 設置容器的 hostname--publish
: 端口轉發規則(8080
:Http 訪問端口映射到Docker80端口,8443
:Https 訪問端口映射到Docker443端口,2222
:主機的 ssh 訪問端口,22
:Docker 容器中 ssh 訪問端口)--name
:容器名稱--restart always
:每次啟動容器就重啟GitLab--volume
: 共享目錄掛載,即 docker 容器內外數據共享(/srv/gitlab/data
: 應用程序數據,/srv/gitlab/logs
:GitLab 的 log,/srv/gitlab/config
:GitLab 的配置文件)--e
:配置 Gitlab 運行的環境變量
這里把主機的8443、8080、2222 端口直接轉發到容器,同時利用 --volume /backup/gitlab/config:/etc/gitlab 、
sudo docker stop gitlab sudo docker rm gitlab
# 配置http協議所使用的訪問地址 external_url 'http://10.200.0.100' # 配置ssh協議所使用的訪問地址和端口 gitlab_rails['gitlab_ssh_host'] = '10.200.0.100' gitlab_rails['gitlab_shell_ssh_port'] = 10022
為了方便,這里直接用宿主機ip來指定。ssh默認使用的端口號是22,但是為了避開與宿主機22端口的沖突,這里用了10022。通過上面的配置,gitlab上的項目生成的訪問地址如下:
# HTTP http://10.200.0.100/root/test-docker-gitlab.git # SSH ssh://git@10.200.0.100:10022/root/test-docker-gitlab.git
5. 配置郵件發送功能
個人覺得gitlab服務器發送郵件的功能是必不可少的,尤其是在用戶注冊時,通知用戶設置密碼也是通過發送郵件來完成的。這里也是修改gitlab.rb配置文件來完成。
# 這里以新浪的郵箱為例配置smtp服務器 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.sina.com" gitlab_rails['smtp_port'] = 25 gitlab_rails['smtp_user_name'] = "name4mail" gitlab_rails['smtp_password'] = "passwd4mail" gitlab_rails['smtp_domain'] = "sina.com" gitlab_rails['smtp_authentication'] = :login gitlab_rails['smtp_enable_starttls_auto'] = true # 還有個需要注意的地方是指定發送郵件所用的郵箱,這個要和上面配置的郵箱一致 gitlab_rails['gitlab_email_from'] = 'name4mail@sina.com'
注意,每次修改gitlab.rb配置文件之后,或者在容器里執行gitlab-ctl reconfigure命令,或者重啟容器以讓新配置生效。
5. 其他
1) 如果想要支持https的話,還需要配置一下nginx;
2) 如果不想在登錄界面出現用戶自注冊的輸入界面的話,可以在Admin Area->Settings->Sign-in Restrictions里將Sign-up enabled選項去掉;
3) 國內的網絡大家都懂的,gitlab使用的Gravatar頭像時常顯示不出來,如果不想用這功能,可以在Admin Area->Settings->Account and Limit Settings里將Gravatar enabled選項去掉;
…