Windows上的Docker端口绑定不起作用

时间:2019-06-12 11:49:14

标签: windows docker

我注意到在我新创建的Docker容器上的网络停止在Windows 10笔记本电脑上工作,因此我学习了基础知识,并运行了Windows Web服务器映像microsoft / iis:nanoserver。

我用命令运行它: docker run -d -p 8080:80 --name web microsoft/iis:nanoserver

但是浏览http://localhost:8080却一无所获。 netstat -a在端口8080上未侦听。

发生在我与docker-compose一起玩之后,我给了几个容器他们自己的网络。我想那之后我把它留在一个奇怪的状态吗?

当我切换到linux容器时,一切正常。

docker inspect web返回:

[
    {
        "Id": "67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22",
        "Created": "2019-06-12T11:33:08.7197232Z",
        "Path": "C:\\ServiceMonitor.exe",
        "Args": [
            "w3svc"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1604,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2019-06-12T11:33:36.5159265Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:d4d34a16ef9d92b7fba6c81d175ee221b3326420928338523f1f52e2f8925042",
        "ResolvConfPath": "",
        "HostnamePath": "",
        "HostsPath": "",
        "LogPath": "C:\\ProgramData\\Docker\\containers\\67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22\\67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22-json.log",
        "Name": "/web",
        "RestartCount": 0,
        "Driver": "windowsfilter",
        "Platform": "windows",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "8080"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 0,
            "ConsoleSize": [
                81,
                226
            ],
            "Isolation": "hyperv",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DiskQuota": 0,
            "KernelMemory": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": 0,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": null,
            "ReadonlyPaths": null
        },
        "GraphDriver": {
            "Data": {
                "dir": "C:\\ProgramData\\Docker\\windowsfilter\\67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22"
            },
            "Name": "windowsfilter"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "67d95234c37c",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "80/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "microsoft/iis:nanoserver",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "C:\\ServiceMonitor.exe",
                "w3svc"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "8080"
                    }
                ]
            },
            "SandboxKey": "67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "",
            "Gateway": "",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "",
            "IPPrefixLen": 0,
            "IPv6Gateway": "",
            "MacAddress": "",
            "Networks": {
                "nat": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "87bd53961ec7b882aa19f6bd45d1a4c6200845d83b1547e8e24e9f8ac62eef7a",
                    "EndpointID": "59b66765ffaecf14024b032236fcfbb4f7c6a4eb3eac6c074f83165706d3fc08",
                    "Gateway": "172.30.80.1",
                    "IPAddress": "172.30.81.248",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "00:15:5d:86:12:5c",
                    "DriverOpts": null
                }
            }
        }
    }
]

docker network inspect nat返回:

[
    {
        "Name": "nat",
        "Id": "87bd53961ec7b882aa19f6bd45d1a4c6200845d83b1547e8e24e9f8ac62eef7a",
        "Created": "2019-06-06T15:53:56.9856162+02:00",
        "Scope": "local",
        "Driver": "nat",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "windows",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.30.80.0/20",
                    "Gateway": "172.30.80.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "67d95234c37c9a851cb5f7c5fc8131c155030ec729e982ad8716c2fd83d0ff22": {
                "Name": "web",
                "EndpointID": "59b66765ffaecf14024b032236fcfbb4f7c6a4eb3eac6c074f83165706d3fc08",
                "MacAddress": "00:15:5d:86:12:5c",
                "IPv4Address": "172.30.81.248/16",
                "IPv6Address": ""
            }
        },
        "Options": {
            "com.docker.network.windowsshim.hnsid": "03ba435e-d884-4daf-b8a5-3b066b4cc410",
            "com.docker.network.windowsshim.networkname": "nat"
        },
        "Labels": {}
    }
]

0 个答案:

没有答案