安装docker
为了安装较新版的docker首先修改yum源
# step 1: 安装必要的一些系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装Docker-CE
yum makecache fast
yum -y install docker-ce
# Step 4: 开启Docker服务
systemctl start docker
安装docker-compose
yum -y install epel-release docker-compose
创建yaml文件
networks:
wordpress:
services:
wordpress:
image: wordpress:5.2.2-php7.3-apache
restart: always
ports:
- 8443:443
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: {{.db_user}}
WORDPRESS_DB_PASSWORD: {{.db_password}}
WORDPRESS_DB_NAME: {{.db_database}}
HTTP_X_FORWARDED_PROTO: https
volumes:
#1,2,3均为了设置自动开启ssl
- ./volumes/wordpress/sp-config/mods-enabled/ssl.load:/etc/apache2/mods-enabled/ssl.load
- ./volumes/wordpress/sp-config/mods-enabled/ssl.conf:/etc/apache2/mods-enabled/ssl.conf
- ./volumes/wordpress/sp-config/mods-enabled/socache_shmcb.load:/etc/apache2/mods-enabled/socache_shmcb.load
#mount证书
- ./volumes/nginx/certs:/certs
#mount443监听配置,配置证书
- ./volumes/wordpress/sp-config/sites-available/:/etc/apache2/sites-enabled/
#持久化网站信息,由于暂不清楚那些文件必须持久化,所以暂时全部mount
- ./volumes/wordpress/mysite-html:/var/www/html/
networks:
- wordpress
depends_on:
- db
db:
image: mysql:5.7
restart: always
environment:
MYSQL_DATABASE: {{.db_database}}
MYSQL_USER: {{.db_user}}
MYSQL_PASSWORD: {{.db_password}}
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- ./volumes/mysql/mysql-storage:/var/lib/mysql
ports:
- 3306:3306
networks:
- wordpress
ng:
image: nginx:1.9.5
restart: always
volumes:
- ./volumes/nginx/certs:/certs
- ./volumes/nginx/nginx.conf:/etc/nginx/nginx.conf
networks:
- wordpress
ports:
- 8089:80
- 443:443
depends_on:
- wordpress
运行
docker-compose up -d