Docker 安装、运行、gitlab-ce
·
一、docker部署
下载镜像(中文社区版)
docker pull beginor/gitlab-ce
查看镜像
[root@gitrunner gitcs]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
beginor/gitlab-ce latest 5595d4ff803e 13 months ago 1.5GB
[root@gitrunner gitcs]#
在宿主机创建映射文件夹
[root@gitrunner gitcs]# pwd
/home/gitcs
[root@gitrunner gitcs]# mkdir -p gitlab/etc gitlab/log gitlab/data
[root@gitrunner gitcs]# ll
total 4
drwxr-xr-x 5 root root 4096 Jul 18 09:36 gitlab
[root@gitrunner gitcs]# cd gitlab/
[root@gitrunner gitlab]# ll
total 12
drwxr-xr-x 2 root root 4096 Jul 18 09:36 data
drwxr-xr-x 2 root root 4096 Jul 18 09:36 etc
drwxr-xr-x 2 root root 4096 Jul 18 09:36 log
给文件夹授权
不要忘记给文件夹授权,要不然它就会因为没有权限创建文件夹而无限重启了!
[root@gitrunner gitlab]# cd ..
[root@gitrunner gitcs]# ll
total 4
drwxr-xr-x 5 root root 4096 Jul 18 09:36 gitlab
[root@gitrunner gitcs]# chmod -R 777 gitlab/
[root@gitrunner gitcs]# ll
total 4
drwxrwxrwx 5 root root 4096 Jul 18 09:36 gitlab
[root@gitrunner gitcs]#
启动容器
docker run -d -p 80:80 --restart always -v /home/gitcs/gitlab/etc:/etc/gitlab -v /home/gitcs/gitlab/log:/var/log/gitlab -v /home/gitcs/gitlab/data:/var/opt/gitlab --name='gitlab-zh' --hostname='ip' 5595d4ff803e
ip:8080登录
[root@gitrunner data]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
964f2331b110 5595d4ff803e "/assets/wrapper" 2 minutes ago Up 2 minutes (healthy) 22/tcp, 443/tcp, 0.0.0.0:8080->80/tcp gitlab-zh
[root@gitrunner data]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3329/sshd
tcp6 0 0 :::8080 :::* LISTEN 16854/docker-proxy
udp 0 0 0.0.0.0:68 0.0.0.0:* 2957/dhclient
udp 0 0 127.0.0.1:323 0.0.0.0:* 2276/chronyd
udp6 0 0 ::1:323 :::* 2276/chronyd
常见问题
如果在容器启动时 不指定 --hostname=‘你的域名’ 就会出现如下问题
gitlab服务器启动后, 新建一个项目, 但项目的地址是这样的, 本来应该是域名位置确变成了 Docker容器的ID
http://eac9d06da1f7/Groups-SmallPrograms/test.git
二、docker-compose部署
cat gitlab_docker-compose.yml
version: '3'
services:
gitlab:
image: beginor/gitlab-ce:11.3.0-ce.0
ports:
- 8443:443
- 8080:80
container_name: gitlab-ce
restart: unless-stopped
volumes:
- /home/gitlab/etc:/etc/gitlab
- /home/gitlab/log:/var/log/gitlab
- /home/gitlab/data:/var/opt/gitlab
# 设置容器的权限为root
privileged: true
hostname: gitlab-ce-test1
启动:
docker-compose -f gitlab_docker-compose.yml up -d
clone项目
git clone http://1.0.0.0:8080/root/test1.git
更多推荐



所有评论(0)