Aucune description

zhensolid 6dd26cf055 update il y a 1 an
mysql b1ef2bdf76 update il y a 1 an
nginx b1ef2bdf76 update il y a 1 an
redis b1ef2bdf76 update il y a 1 an
server b1ef2bdf76 update il y a 1 an
.gitignore f5c0c395ea Initial commit il y a 1 an
LICENSE f5c0c395ea Initial commit il y a 1 an
README.md 6dd26cf055 update il y a 1 an
docker-compose.yaml 1c17f528c3 update il y a 1 an

README.md

1.1 目录结构

campus-imaotai-docker/
├── docker-compose.yml
├── mysql/
│   ├── conf/
│   ├── data/
│   ├── logs/
│   └── campus_imaotai.sql
├── redis/
│   ├── conf/
│   │   └── redis.conf
│   └── data/
├── nginx/
│   ├── conf/
│   │   └── nginx.conf
│   ├── html/
│   ├── cert/
│   └── log/
└── server/
    └── conf/
        └── application-prod.yml

1.2 创建必要目录

chmod 777 redis/data
chmod 777 mysql/data
chmod 777 mysql/logs

二、网络配置

2.1 删除之前创建的 imaotai 网络

docker network rm imaotai

2.2 查看创建的 imaotai 网络是否开启ip_masquerade

docker network inspect imaotai

2.3 如果需要重新创建,使用portainer创建比较方便

docker network create \
  --driver bridge \
  --opt "com.docker.network.bridge.enable_ip_masquerade=true" \
  --subnet=172.20.0.0/16 \
  --gateway=172.20.0.1 \
  imaotai

2.4 网络须知

一个是imaotai可以访问外网,一个是campus-imaotai只能访问内网,所以需要创建两个网络并且固定ip范围避免容器只通过captus-imaotai网络访问内网,导致无法访问外网 imaotai部署172.20.0.0/16网段 campus-imaotai在docker-compose部署172.22.0.0/16网段 并且在docker-compose.yml中指令配置campus-server的ip route指向imaotai网关172.20.0.1 还需要部署防火墙,让容器网络172.20.0.0/16能够访问外网

  iptables -t nat -A POSTROUTING -s 172.20.0.0/16 -j MASQUERADE

三、启动容器

先使用指令启用mysql

   docker-compose up -d mysql

然后在启动所有容器

   docker-compose up -d