一、安装docker-compose包
yum install docker-compose.noarch -y
二、导入wordpress镜像
docker load -i wordpress-latest.tar.gz
三、创建docker-compose文件
mkdir /data/docker-compose/wordpress
vim docker-compose.yaml
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
volumes:
- web_data:/var/www/html
ports:
- "80:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data:
web_data:
四、启动docker-compose
docker-compose up
docker-compose up -d
五、浏览器访问测试
image.png
网友评论