当前位置:网站首页>centos8使用docker安装wordpress+mysql配置文件中WORDPRESS_DB_HOST的理解
centos8使用docker安装wordpress+mysql配置文件中WORDPRESS_DB_HOST的理解
2022-07-28 16:38:00 【Ripo_za】
这篇博客提到了我按照docker官网安装wordpress遇到的问题。可能这是centos8特有的问题吧。经过了解我确定不是docker官网composse文件问题。下面是我对于compose的理解。
下面compose文件几乎和官方一样,只是volumes挂在有些不同。
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- ./db_data:/var/lib/mysql
restart: always
ports:
- "3307:3306"
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
#这里与上面的mysql对应。
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
volumes:
- ./wordpress:/var/www/html
environment:
#这里的db就代表上面mysql容器主机
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {
}
wordpress:
主要看WORDPRESS_DB_HOST字段,该字段对应wp-config.php中的DB_HOST字段值。这个值可以有三种填法,但后面两种只是可以运行的做法,不要实际这样做。
(1)这里的db指的就是mysql服务(ip+默认3306端口,如果是别的应该要明确指出来),后面的端口就是指的是mysql容器中对应的端口。如果是3006的话也可以省略不写。但最好还是在mysql和wordpress中都指明,清楚点。
(2)根据第一点,如果更改wp-config.php中的DB_HOST字段值为 mysql容器的ip+端口也可以运行,根据下面的内容可以改成172.19.0.2:3306。
(3)第二点也可以写成运行wordpress的容器的网关地址+mysql隐射端口。根据下面的图,可以写成172.19.0.1:3307。
后两种方法的执行需要先生成两个容器,然后查询对应的Gataway变量,然后修改wordpress对应的wp-config.php表才行。这只是可以运行的方法,但是不要这样做。而且在重新运行该容器后,wp-config.php的值会变回去。
同一个compose文件运行的容器都在同一网关下。见下图。
(1)wordpress输出的inspect部分信息
(2)mysql输出的部分信息
边栏推荐
- [advanced C language] - analyze the storage of micro data in memory [i]
- 编译原理学习笔记1(编译原理概述与词法分析)
- ps快速制作全屏水印
- MySQL详解
- IDEA报错Error running ‘Application‘ Command line is too long解决方案
- Mmdetection3d (2) -- visualization of results and logs
- [C language must see] yo, writing bugs, I'm sure you've stepped on the pit
- [unity] timeline learning notes (VII): Custom clip
- [C language note sharing] character function and string function (recommended Collection)
- 分支与循环语句
猜你喜欢

方法、函数

Three ways to dynamically call WebService.Net
![[C language note sharing] custom type: structure, enumeration, Union (recommended Collection)](/img/25/4a17c260b2b506ae1224520d9b85d1.png)
[C language note sharing] custom type: structure, enumeration, Union (recommended Collection)

2022 IDEA (学生邮箱认证)安装使用教程以及基础配置教程

abstract、static、final
![[advanced C language] - Advanced pointer [i]](/img/62/d3410a61b931177fc02c1801489b5a.png)
[advanced C language] - Advanced pointer [i]
@Detailed explanation of requestmapping

Mmdetection3d (2) -- visualization of results and logs

How to install PS filter plug-in

OpenMV(六)--STM32实现物体识别与手写数字识别
随机推荐
1.2-hexadecimal conversion
Point cloud processing voxel filter
数字滤波器(六)--设计FIR滤波器
域名解析问题记录
ROS system installation
LeetCode--45. 跳跃游戏Ⅱ(贪心)
1.1- notes
Pycharm connects to remote docker
移动端overflow失效问题
Point cloud processing -- binary tree
Tips--解决No module named matlab.engine的问题
ROS custom message and use
TensorFlow2.0(十一)--理解LSTM网络
OpenMV(三)--实时获取摄像头图片
Electrotechnics self study notes 1.22
【p5.js实战】我的自画像
Mmdetection3d (3) -- network output
【Unity】Sprite九宫格到底怎么玩?
Ros自定义消息及使用
Domain name resolution problem record