使用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=%257B%2522request%255Fid%2522%253A%2522168623078216800225583599%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168623078216800225583599&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-11-121335929-null-null.268%5Ev1%5Ekoosearch&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