gpt4 book ai didi

docker - 使用docker时无法访问phpmyadmin

转载 作者:行者123 更新时间:2023-12-02 18:43:40 25 4
gpt4 key购买 nike

我在项目上使用docker,并按如下所示设置了docker-compose文件:

    db_service:
container_name: database
image: mysql:latest
ports:
- "3306:3306"
environment:
- MYSQL_USER=root
- MYSQL_PASSWORD=mypassword
- MYSQL_ROOT_PASSWORD=mypassword
- MYSQL_DATABASE=my_database

phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
ports:
- "8082:80"

当我在 http://localhost:8082上登录phpmyadmin时,它显示错误

mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed:
Name does not resolve



enter image description here

有谁知道如何解决此问题?

最佳答案

尝试链接,依赖和环境变量PMA_HOST

db_service:

 container_name: database
image: mysql:latest
ports:
- "3306:3306"
environment:
- MYSQL_USER=root
- MYSQL_PASSWORD=mypassword
- MYSQL_ROOT_PASSWORD=mypassword
- MYSQL_DATABASE=my_database
phpmyadmin:

image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
depends_on:
- database
links:
- database
ports:
- "8082:80"

environment:

   - MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=mypassword
- MYSQL_PASSWORD=mypassword
- PMA_HOST=database

关于docker - 使用docker时无法访问phpmyadmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51522385/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com