meface/docs/article/devops/docker/docker_example.md

72 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### Docker 搭建git私服Gitea
#### 1.安装docker
```shell
yum install docker -y
systemctl start docker
```
更换成国内的源,登陆阿里云找到镜像服务=》镜像工具=》镜像加速:
```shell
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://gbi3l7ww.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
```
通过修改daemon配置文件/etc/docker/daemon.json来使用加速器。
#### 2. 数据库准备
> 安装Postgres
```shell
[root@VM-8-4-centos pg]# docker search postgres
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/postgres he PostgreSQL ... 12786 [OK]
docker.io docker.io/bitnami/postgresql Bitnami PostgreSQL Docker Image 244 [OK]
[root@VM-8-4-centos pg]# pwd
/usr/local/pg
# 创建配置文件
[root@VM-8-4-centos pg]# vim pg.env
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_PASSWORD=qsj123456
POSTGRES_PORT=5437
POSTGRES_DEVELOPMENT_DATA=/usr/local/pg/data
POSTGRES_LOG=/usr/local/pg/log/
POSTGRES_LOCAL_LOG=/usr/local/pg/local_log/
[root@VM-8-4-centos pg]# export $(grep -v '^#' /usr/local/pg/pg.env |xargs) && docker run -d --rm --name postgres-gitea \
-e POSTGRES_USER=$POSTGRES_USER \
-e POSTGRES_DB=$POSTGRES_DB \
-e POSTGRES_PASSWORD=$POSTGRES_PASSWORD \
-p $POSTGRES_PORT:5432 \
-v $POSTGRES_DEVELOPMENT_DATA:/var/lib/postgresql/data \
postgres
```
#### 3. 安装gitea
```shell
```