Docker 搭建代码仓库 GitLab
-
创建本机目录(保存gitlab数据)
mkdir -p /data/gitlab
-
拉取 GitLab-CE docker镜像
docker pull gitlab/gitlab-ce
-
运行 gitlab 容器
export GITLAB_HOME=/data/gitlab
sudo docker run -d --hostname hostname --publish 10443:443 --publish 10080:80 --publish 10022:22 --name gitlab --restart always \ -v $GITLAB_HOME/config:/etc/gitlab -v $GITLAB_HOME/logs:/var/log/gitlab -v $GITLAB_HOME/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
-
修改配置(/data/gitlab/config/gitlab.rb)
cd /data/gitlab/config
修改 gitlab.rb
### http 端口,对外的端口 external_url 'http://129.204.66.172:10080' ### ssh 端口,对外的端口 gitlab_rails['gitlab_shell_ssh_port'] = 10022 ### 邮箱 smtp 设置 gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.office365.com" gitlab_rails['smtp_port'] = 587 gitlab_rails['smtp_user_name'] = "microestc@outlook.com" gitlab_rails['smtp_password'] = "邮箱密码" gitlab_rails['smtp_domain'] = "smtp.office365.com" gitlab_rails['smtp_authentication'] = "login" gitlab_rails['smtp_enable_starttls_auto'] = true gitlab_rails['smtp_openssl_verify_mode'] = 'peer' gitlab_rails['smtp_tls'] = false ### Email Settings gitlab_rails['gitlab_email_enabled'] = true gitlab_rails['gitlab_email_from'] = 'microestc@outlook.com' gitlab_rails['gitlab_email_display_name'] = 'Microestc' gitlab_rails['gitlab_email_reply_to'] = 'microestc@outlook.com'
-
重新建立容器并运行
docker stop gitlab docker rm gitlab
export GITLAB_HOME=/data/gitlab
sudo docker run -d --hostname hostname --publish 10443:443 --publish 10080:10080 --publish 10022:22 --name gitlab --restart always \ -v $GITLAB_HOME/config:/etc/gitlab -v $GITLAB_HOME/logs:/var/log/gitlab -v $GITLAB_HOME/data:/var/opt/gitlab \ gitlab/gitlab-ce:latest
-
附加
sudo docker run -d --hostname my.domain.com --publish 10443:443 --publish 10080:10080 --publish 10022:22 --name gitlab --restart always \ -v $GITLAB_HOME/config:/etc/gitlab -v $GITLAB_HOME/logs:/var/log/gitlab -v $GITLAB_HOME/data:/var/opt/gitlab \ --env GITLAB_OMNIBUS_CONFIG="external_url 'http://my.domain.com:10080'; gitlab_rails['gitlab_shell_ssh_port'] = 10022;" \ gitlab/gitlab-ce:latest