运行环境:VMware Station 12;虚拟机中安装Centos 7系统;虚拟机可访问互联网
1、新建一个docker-compose.yml:vi docker-compose.yml
2、在docker-compose.yml中,粘贴以下代码:
version: ‘3.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
ports:
– “8000:80”
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
:wq保存退出
3、运行:docker-compose up -d
4、在浏览器中访问http://MACHINE_VM_IP:8000即可
原文链接:https://blog.csdn.net/u013392078/article/details/103808376?ops_request_misc=&request_id=d03d454821fa40db84ee36359e962fbd&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-29-103808376-null-null.268%5Ev1%5Econtrol&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81