一. 安装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选项去掉;
…