mysql – php_network_getaddresses:geterdrinfo在Docker的adminer中失败了

前端之家收集整理的这篇文章主要介绍了mysql – php_network_getaddresses:geterdrinfo在Docker的adminer中失败了前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我在使用laravel 5 / mysql应用程序访问我的docker容器中的adminer时遇到问题.我收到了错误

sqlSTATE[HY000] [2002] PHP_network_getaddresses: getaddrinfo Failed: Name does not resolve

我的docker-compose.yml:

version: '3'

services:

    votes_app:
        build:
            context: ./web
            dockerfile: Dockerfile.yml

        container_name: votes_app_container
        environment:
            - APACHE_RUN_USER=#1000
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        ports:
            - 8081:80
        working_dir: ${APP_PTH_CONTAINER}


    votes_db:
        image: MysqL:5.6.41
        container_name: votes_db_container

        restart: always
        environment: 
            MysqL_ROOT_PASSWORD: 1
        volumes:
            - ${DB_PATH_HOST}:/var/lib/MysqL


    votes_adminer:
        image: adminer
        container_name: votes_adminer_container
        restart: always
        ports:
            - 8082:8080
        links:
            - votes_db


    votes_composer:
        image: composer:1.6
        container_name: votes_composer_container
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

我为app和db容器提供了不同的端口.

这里https://hub.docker.com/_/adminer/我发现:

Usage with external server You can specify the default host with the
ADMINER_DEFAULT_SERVER environment variable. This is useful if you are
connecting to an external server or a docker container named something
other than the default db.

docker run -p 8080:8080 -e ADMINER_DEFAULT_SERVER=MysqL adminer

在我的应用程序的控制台中我运行命令

$docker run -p 8089:8080 -e ADMINER_DEFAULT_SERVER=votes_db adminer 

在我的应用程序端口中未使用,并且此命令无论如何都不成功,因为我在尝试登录到adminer https://imgur.com/a/4HCdC1W时遇到了同样的错误.

哪种方法正确?

修改块#2:

在我的docker-compose.yml中:

version: '3'

services:

    votes_app:
        build:
            context: ./web
            dockerfile: Dockerfile.yml

        container_name: votes_app_container
        environment:
            - APACHE_RUN_USER=#1000
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        ports:
            - 8081:80
        working_dir: ${APP_PTH_CONTAINER}


    db:
        image: MysqL:5.6.41
        restart: always
        environment: 
            MysqL_ROOT_PASSWORD: 1
        volumes:
            - ${DB_PATH_HOST}:/var/lib/MysqL


    adminer:
        image: adminer
        restart: always
        ports:
            - 8082:8080
        links:
            - db


    votes_composer:
        image: composer:1.6
        container_name: votes_composer_container
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

我重建了应用程序,但我没有登录到adminer:https://imgur.com/a/JWVGfBA

我在操作系统的控制台中运行指向其他未使用的8089端口:

$docker run -p 8089:8080 -e ADMINER_DEFAULT_SERVER=db adminer
PHP 7.2.11 Development Server started at Thu Nov  1 07:00:46 2018
[Thu Nov  1 07:01:11 2018] ::ffff:172.17.0.1:34048 [200]: /
[Thu Nov  1 07:01:20 2018] ::ffff:172.17.0.1:34052 [302]: /
[Thu Nov  1 07:01:21 2018] ::ffff:172.17.0.1:34060 [403]: /?server=db&username=root

但再次错误登录到8089端口的adminer,但错误消息不同:

https://imgur.com/a/a8qM4bt

怎么了 ?

修改块#3:

我想是的,因为在我重建了容器之后,我进入了框并在控制台输出中看到“root”:

$docker-compose exec votes_app bash
root@a4aa907373f5:/var/www/html# ls -la
total 1063
drwxrwxrwx 1 root root   4096 Oct 27 12:01 .
drwxr-xr-x 1 root root   4096 Oct 16 00:11 ..
-rwxrwxrwx 1 root root    234 Oct 13 07:15 .editorconfig
-rwxrwxrwx 1 root root   1029 Oct 31 06:10 .env
-rwxrwxrwx 1 root root    651 Oct 13 07:15 .env.example
drwxrwxrwx 1 root root   4096 Nov  1 11:10 .git
-rwxrwxrwx 1 root root    111 Oct 13 07:15 .gitattributes
-rwxrwxrwx 1 root root    294 Oct 13 07:15 .gitignore
-rwxrwxrwx 1 root root   4356 Oct 13 07:15 1.txt
drwxrwxrwx 1 root root      0 Oct 13 07:15 __DOCS
drwxrwxrwx 1 root root      0 Oct 13 07:15 __sql
drwxrwxrwx 1 root root   4096 Oct 13 07:15 app
-rwxrwxrwx 1 root root   1686 Oct 13 07:15 artisan                                                                                                                                                                     
drwxrwxrwx 1 root root      0 Oct 13 07:15 bootstrap                                                                                                                                                                   
-rwxrwxrwx 1 root root   2408 Oct 13 07:15 composer.json                                                                                                                                                               
-rwxrwxrwx 1 root root 200799 Oct 13 07:15 composer.lock                                                                                                                                                               
drwxrwxrwx 1 root root   4096 Oct 13 07:15 config                                                                                                                                                                      
drwxrwxrwx 1 root root   4096 Oct 13 07:15 database                                                                                                                                                                    
-rwxrwxrwx 1 root root  52218 Oct 17 05:25 db_1_err.txt                                                                                                                                                                
-rwxrwxrwx 1 root root 482562 Oct 13 07:15 package-lock.json                                                                                                                                                           
-rwxrwxrwx 1 root root   1168 Oct 13 07:15 package.json                                                                                                                                                                
-rwxrwxrwx 1 root root   1246 Oct 13 07:15 PHPunit.xml                                                                                                                                                                 
drwxrwxrwx 1 root root   4096 Oct 13 07:15 public
-rwxrwxrwx 1 root root     66 Oct 13 07:15 readme.txt
drwxrwxrwx 1 root root      0 Oct 13 07:15 resources
drwxrwxrwx 1 root root   4096 Oct 13 07:15 routes
-rwxrwxrwx 1 root root    563 Oct 13 07:15 server.PHP
drwxrwxrwx 1 root root   4096 Oct 13 07:15 storage
drwxrwxrwx 1 root root      0 Oct 13 07:15 tests
drwxrwxrwx 1 root root   8192 Nov  1 13:05 vendor
-rwxrwxrwx 1 root root   1439 Oct 13 07:15 webpack.mix.js
-rwxrwxrwx 1 root root 261143 Oct 13 07:15 yarn.lock
root@a4aa907373f5:/var/www/html# echo $USER

root@a4aa907373f5:/var/www/html#  uname -a
Linux a4aa907373f5 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 GNU/Linux

无论如何它可以成为问题吗?

谢谢!

最佳答案
你可以看到它
https://hub.docker.com/_/adminer/

version: '3.1'

services:

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

  db:
    image: MysqL:5.6
    restart: always
    environment:
      MysqL_ROOT_PASSWORD: example
原文链接:https://www.f2er.com/docker/436000.html

猜你在找的Docker相关文章