🎈 作者: 互联网-小啊宇
🎈 简介: CSDN 运维领域创作者。目前从事 Kubernetes运维相关工作,擅长Linux系统运维、开源监控软件维护、Kubernetes容器技术、CI/CD持续集成、自动化运维、开源软件部署维护等领域。
🎈 博客首页: 互联网-小啊宇
🎈 欢迎小伙伴们点赞👍、收藏⭐、留言💬
⭐服务器准备
使用VMware创建的虚拟机2C 8G
保证能联网
🍒确保网络正常、能联网
[root@localhost ~]# ping -c1 www.baidu.com
PING www.a.shifen.com (110.242.68.3) 56(84) bytes of data.
64 bytes from 110.242.68.3 (110.242.68.3): icmp_seq=1 ttl=128 time=12.2 ms
--- www.a.shifen.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 12.255/12.255/12.255/0.000 ms
🍒查看本机IP
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.222 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::69d5:a47:9ac5:610 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:de:64:dc txqueuelen 1000 (Ethernet)
RX packets 901566 bytes 1331763183 (1.2 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 122361 bytes 11860792 (11.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
🍒服务器2核8G
[root@localhost ~]# cat /proc/cpuinfo | grep "processor" | wc -l
2
[root@localhost ~]# free -h
total used free shared buff/cache available
Mem: 7.6G 176M 7.2G 11M 224M 7.2G
Swap: 2.0G 0B 2.0G
⭐服务器安装Docker
🍒关闭防火墙、沙盒、IP tables
systemctl stop firewalld && systemctl disable firewalld && setenforce 0 && iptables -F && iptables-save
🍒下载Docker
yum -y install docker
🍒查看版本
[root@localhost ~]# docker --version
Docker version 1.13.1, build 7d71120/1.13.1
🍒启动Docker并设置自启动
systemctl start docker && systemctl enable docker
⭐GitLab安装
🍒搜索GitLab镜像
第一个是英文版
第二个是汉化版
根据自己需求使用镜像
[root@localhost ~]# docker search gitlab-ce
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/gitlab/gitlab-ce GitLab Community Edition docker image base... 3642 [OK]
docker.io docker.io/twang2218/gitlab-ce-zh 汉化的 GitLab 社区版 Docker Image 258 [OK]
...
🍒下载GitLab镜像
docker pull gitlab/gitlab-ce
🍒查看镜像详细信息
docker inspect gitlab/gitlab-ce
🍒查看容器内端口、以及相关目录
"ExposedPorts": {
"22/tcp": {},
"443/tcp": {},
"80/tcp": {}
},
"Volumes": {
"/etc/gitlab": {},
"/var/log/gitlab": {},
"/var/opt/gitlab": {}
},
🍒宿主机创建相关目录
mkdir -p /mnt/gitlab/etc
mkdir -p /mnt/gitlab/log
mkdir -p /mnt/gitlab/data
🍒启动GitLab容器
docker run -d -p 8443:443 -p 8080:80 -p 8822:22 --name gitlab --restart always -v /mnt/gitlab/etc:/etc/gitlab -v /mnt/gitlab/logs:/var/log/gitlab -v /mnt/gitlab/data:/var/opt/gitlab --privileged=true gitlab/gitlab-ce
🍒配置GitLab
vim /mnt/gitlab/etc/gitlab.rb
#配置http协议所使用的访问地址,填写宿主机映射端口,不加端口号默认为80;
32行# external_url 'http://192.168.1.222'
#配置ssh协议所使用的访问地址和端口
66行# gitlab_rails['gitlab_ssh_host'] = '192.168.1.222'
650行# gitlab_rails['gitlab_shell_ssh_port'] = 8822
🍒配置完成,重启GitLab容器
docker restart gitlab
🍒查看GitLab的root密码
宿主机查看:
[root@localhost ~]# cat /mnt/gitlab/etc/initial_root_password
容器查看:
[root@localhost ~]# docker exec -it gitlab cat /etc/gitlab/initial_root_password