我正在尝试使用docker-compose.yml
设置一个用于WordPress开发的docker容器,如下所示:
version: '3'
services:
db:
image: mysql:5.7
volumes:
- data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: root
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- 8080:80
- 443:443
volumes:
- ./data:/data # Required if importing an existing database
- ./:/var/www/html # Theme development
environment:
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: root
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:80
volumes:
data: {}
我得到这样的错误:
wordpress_1 | Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22
wordpress_1 |
wordpress_1 | Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22
wordpress_1 |
wordpress_1 | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known
我尝试清理我的图像和容器,但没有运气。知道为什么会这样吗?
答案 0 :(得分:0)
尝试为wordpress和phpmyadmin提供链接选项。
links:
- db:mysql
修改:检查this问题。将mysql添加到db。我不知道如果这个解决了,我必须在我以后回家时尝试一下。