yum install epel-release -y
ll /etc/yum.repos.d/|grep -w epel
yum install docker -y
yum list docker
rpm -qa|grep docker
systemctl start docker.service
ps -ef|grep docker
docker version
docker ps
docker pull gitlab/gitlab-ce:latest
docker images
docker run -itd -p 8010:8010 -p 8022:22 \
-v /home/gitlab/etc:/etc/gitlab \
-v /home/gitlab/log:/var/log/gitlab \
-v /home/gitlab/opt:/var/opt/gitlab \
--hostname 192.168.10.99 \
--privileged=true \
--name gitlab \
--restart always \
gitlab/gitlab-ce
docker exec -it gitlab /bin/bash
vi /etc/gitlab/gitlab.rb
#在文件开头加入如下配置
external_url 'http://192.168.10.99:8010' // gitlab访问地址,可以写域名。如果端口不写的话默认为80 端口
gitlab_rails['gitlab_ssh_host'] = '192.168.10.99' // ssh主机ip
gitlab_rails['gitlab_shell_ssh_port'] = 8022 // ssh连接端口
#退出vi模式
gitlab-ctl reconfigure // 让配置生效
vi /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
#修改配置文件端口
port:8010
# 退出vi模式
gitlab-ctl restart // 重启gitlab
exit // 退出容器
cat /home/gitlab/etc/initial_root_password
参考: GitLab上配置SSH Key
docker pull nginx
docker images
mkdir /nginx/conf/default.conf
mkdir /nginx/logs/error.log
vi /nginx/conf/default.conf
#复制下面链接内容,并自行修改(root /usr/share/nginx/html;)中的访问路径
#如果与我一致,应该是(root /nginx/workspace/dist/)
#退出vi模式
链接: nginx default.conf配置文件详解
docker run -itd --name nginx -p 8020:80 -p 443:443 \
-v /nginx/conf/:/etc/nginx/conf.d/ \
-v /nginx/logs/:/var/log/nginx/ \
-v /nginx/workspace/:/nginx/workspace/ \
--privileged=true \
--restart always \
nginx
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://mn7vu22j.mirror.aliyuncs.com"]
}
docker pull jenkins/jenkins:lts
mkdir -p /mydata/jenkins_home
docker run -itd --name=jenkins -p 8030:8080 \
-v /mydata/jenkins_home/:/var/jenkins_home/ \
-v /nginx/workspace/:/nginx_workspace/ \
--privileged=true \
--restart always \
jenkins/jenkins:lts
docker ps(没有找到对应的容器则启动失败)
docker ps -a
docker logs jenkins
chown -R 1000 /mydata/jenkins_home/
docker logs jenkins
gitlab+jenkins配置
参考: gitlab+jenkins自动化部署
gitlab容器内执行gitlab-ctl reconfigure时可能反应时间较长,耐心等待。
gitlab容器启动速度较慢,前几分钟在docker中的状态为unhealthy(在已经完成重新配置的情况下,浏览器访问为502),只需要等待,不要着急,我在本地虚拟机上启动,大概需要十分钟。
jenkins在启动容器时不仅需要映射自己的重要路径,还需要将nginx的工作路径映射到容器内,方便将jenkins获取到的包部署到nginx工作路径上。(如上:-v /nginx/workspace/:/nginx_workspace/)
jenkins的插件源可跟换成国内的http://mirror.xmission.com/jenkins/updates/update-center.json