使用docker-compose一键部署wordpress+mysql环境
version: '3.3' services: mysql: image: mysql:5.7 volumes: - /root/mysql:/var/lib/mysql restart: always ports: - "3307:3306" networks: - mywordpress environment: MYSQL_ROOT_PASSWORD: root12345 MYSQL_DATABASE: wordpress MYSQL_USER: hlqlinux MYSQL_PASSWORD: hlqlinux12345 wordpress: depends_on: - mysql image: wordpress:latest ports: - "8080:80" restart: always networks: - mywordpress environment: WORDPRESS_DB_HOST: mysql:3306 WORDPRESS_DB_USER: hlqlinux WORDPRESS_DB_PASSWORD: hlqlinux12345 WORDPRESS_DB_NAME: wordpress networks: mywordpress:
测试该compose的性能是否达到标准(使用公有云ecs记得提前开放安全区规则)
env查看设置的环境变量
1.验证数据库与mysql之间的交互
登录容器:mysql -uhlqlinux -phlqlinux12345
本地登录mysql:mysql -uhlqlinux -phlqlinux12345 -P3307 -h127.0.0.1(或者容器ip)
其他主机登录该数据库:mysql -uhlqlinux -phlqlinux12345 -P3307 -h主机ip
查看数据库:show databases;
使用数据库:use wordpress;
查看表:show databases;刚建完是没有数据的
2.登录8080端口安装wordpress,发现wordpress会有数据
3.写一篇博客,可以看到文章元数据
4.查看volume卷
5.查看网络
原文链接:https://blog.csdn.net/weixin_47678667/article/details/121335929?ops_request_misc=&request_id=a044aca1869b47408aaae4503d18d443&biz_id=&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~koosearch~default-29-121335929-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