rancher部署三个Wordpress docker-compose.yml脚本
时间: 2024-06-18 14:05:20 浏览: 212
docker-compose.yml
5星 · 资源好评率100%
好的,下面是部署三个WordPress的docker-compose.yml脚本:
```yaml
version: '3'
services:
db1:
image: mysql:5.7
volumes:
- db1-data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: wordpress1
MYSQL_USER: wordpress1
MYSQL_PASSWORD: password
wordpress1:
depends_on:
- "8001:80"
restart: always
environment:
WORDPRESS_DB_HOST: db1:3306
WORDPRESS_DB_NAME: wordpress1
WORDPRESS_DB_USER: wordpress1
WORDPRESS_DB_PASSWORD: password
volumes:
- wp1-data:/var/www/html
db2:
image: mysql:5.7
volumes:
- db2-data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: wordpress2
MYSQL_USER: wordpress2
MYSQL_PASSWORD: password
wordpress2:
depends_on:
- "8002:80"
restart: always
environment:
WORDPRESS_DB_HOST: db2:3306
WORDPRESS_DB_NAME: wordpress2
WORDPRESS_DB_USER: wordpress2
WORDPRESS_DB_PASSWORD: password
volumes:
- wp2-data:/var/www/html
db3:
image: mysql:5.7
volumes:
- db3-data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
MYSQL_DATABASE: wordpress3
MYSQL_USER: wordpress3
MYSQL_PASSWORD: password
wordpress3:
depends_on:
- "8003:80"
restart: always
environment:
WORDPRESS_DB_HOST: db3:3306
WORDPRESS_DB_NAME: wordpress3
WORDPRESS_DB_USER: wordpress3
WORDPRESS_DB_PASSWORD: password
volumes:
- wp3-data:/var/www/html
volumes:
db1-data:
wp1-data:
db2-data:
wp2-data:
db3-data:
wp3-data:
```
以上的脚本通过Docker Compose来部署三个WordPress实例,每个实例都有一个MySQL数据库进行支持,并且每个实例的端口都不同(8001、8002和8003)。在使用时,可以将上面的脚本保存为docker-compose.yml文件,然后在该文件所在目录执行 `docker-compose up -d` 命令即可启动三个WordPress实例。注意需要提前安装好Docker和Docker Compose。
阅读全文