共计 1941 个字符,预计需要花费 5 分钟才能阅读完成。
官网教程
https://docs.gitlab.com/omnib…
搜寻镜像
docker search gitlab
下载镜像文件
docker pull docker.io/gitlab/gitlab-ce
留神:肯定要配置阿里云的减速镜像
创立 GitLab 的配置 (etc)、日志 (log)、数据 (data) 放到容器之外,便于日后降级,因而请先筹备这三个目录。
mkdir -p /mnt/gitlab/etc
mkdir -p /mnt/gitlab/log
mkdir -p /mnt/gitlab/data
运行 GitLab 容器
docker run \
--detach \
--publish 2222:22 \
--publish 8090:80 \
--publish 8443:443 \
--hostname x.x.x.x \
-v /mnt/gitlab/etc:/etc/gitlab \
-v /mnt/gitlab/log:/var/log/gitlab \
-v /mnt/gitlab/data:/var/opt/gitlab \
-v /etc/localtime:/etc/localtime:ro \
--name gitlab \
--restart always \
--privileged=true gitlab/gitlab-ce:latest
运行胜利之后,将挂载文件同步到容器里面
批改 /mnt/gitlab/etc/gitlab.rb
把 external_url 改成部署机器的域名或者 IP 地址
vim /mnt/gitlab/etc/gitlab.rb
external_url ‘http://x.x.x.x’
批改 /mnt/gitlab/data/gitlab-rails/etc/gitlab.yml
vim /mnt/gitlab/data/gitlab-rails/etc/gitlab.yml
找到关键字 ## Web server settings
咱们进到目录再看一下挂载文件是否同步到里面来了
[root@VM-0-16-centos gitlab]# ls /mnt/gitlab/*
/mnt/gitlab/data:
alertmanager backups bootstrapped gitaly git-data gitlab-ci gitlab-exporter gitlab-rails gitlab-shell gitlab-workhorse grafana logrotate nginx postgres-exporter postgresql prometheus public_attributes.json redis trusted-certs-directory-hash
/mnt/gitlab/etc:
gitlab.rb gitlab-secrets.json ssh_host_ecdsa_key ssh_host_ecdsa_key.pub ssh_host_ed25519_key ssh_host_ed25519_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub trusted-certs
/mnt/gitlab/log:
alertmanager gitaly gitlab-exporter gitlab-rails gitlab-shell gitlab-workhorse grafana logrotate nginx postgres-exporter postgresql prometheus puma reconfigure redis redis-exporter sidekiq sshd
[root@VM-0-16-centos gitlab]#
这个时候咱们把容器进行再删除,而后重启服务
[root@localhost ~]# docker stop [容器 ID]
[root@localhost ~]# docker rm [容器 ID]
[root@localhost ~]# systemctl restart docker
再来从新创立容器
docker run \
--detach \
--publish 2222:22 \
--publish 8090:80 \
--publish 8443:443 \
--hostname x.x.x.x \
-v /mnt/gitlab/etc:/etc/gitlab \
-v /mnt/gitlab/log:/var/log/gitlab \
-v /mnt/gitlab/data:/var/opt/gitlab \
-v /etc/localtime:/etc/localtime:ro \
--name gitlab \
--restart always \
--privileged=true gitlab/gitlab-ce:latest
网页拜访 8090 端口,初始用户为 root
正文完