Windows 10上的docker:容器没有IP地址

时间:2018-09-17 09:14:47

标签: docker localhost containers

第一步:我从本地驱动器加载了图像:

docker load -i postgres10.tar
docker load -i drupaldrush1.tar

第二步:我启动了容器:

 docker run -p5432:5432 postgres:10
 docker run -p8081:8081 drupaldrush:1

第三步:显示容器:

docker ps

导致:

CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                            NAMES
b77bcc79d599        drupaldrush:1       "docker-php-entrypoi…"   33 seconds ago       Up 32 seconds       80/tcp, 0.0.0.0:8081->8081/tcp   flamboyant_easley
97b9ba5f2779        postgres:10         "docker-entrypoint.s…"   About a minute ago   Up About a minute   0.0.0.0:5432->5432/tcp           competent_fermat

BUT容器在以下位置不可用:localhost:8081

第四步:检查容器:

 docker inspect flamboyant_easley

(除其他信息外)产生的结果:

"HostConfig": {
        "Binds": null,
        "ContainerIDFile": "",
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "NetworkMode": "default",
        "PortBindings": {
            "8081/tcp": [
                {
                    "HostIp": "",
                    "HostPort": "8081"
                }
            ]
        },

  "IPAddress": "172.17.0.3",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",

        "Networks": {
            "bridge": {
                "IPAMConfig": null,
                "Links": null,
                "Aliases": null,
                "NetworkID": "d5e552bf9c57050fe2debfc7d38a784580309fa0b72c4854a563e78295128912",
                "EndpointID": "f61b02c5997b2e391add348686f658b4c596dd60495365cee0fee539743d4792",
                "Gateway": "172.17.0.1",
                "IPAddress": "172.17.0.3",
                "IPPrefixLen": 16,
                "IPv6Gateway": "",
                "GlobalIPv6Address": "",
                "GlobalIPv6PrefixLen": 0,    

问题:容器在localhost:8081下不可用,并且在172.17.0.3:8081或172.17.0.1:8081下不可用 问题:如何使它在localhost:8081下运行?

1 个答案:

答案 0 :(得分:0)

问题来自Windows的Docker。现在我有了一台Linux笔记本电脑,一切正常。