当前位置: 首页 > 知识库问答 >
问题:

无法使用IP地址运行docker

长孙章横
2023-03-14
[
    {
        "Id": "c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7",
        "Created": "2020-08-19T18:17:50.917578Z",
        "Path": "java",
        "Args": [
            "-jar",
            "/app.jar"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 3142,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2020-08-19T18:17:53.0308405Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:04d86c26964a44e147a0132bc6f6810f5aeba005d655b0d0b86f04499fc6a7a1",
        "ResolvConfPath": "/var/lib/docker/containers/c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7/hostname",
        "HostsPath": "/var/lib/docker/containers/c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7/hosts",
        "LogPath": "/var/lib/docker/containers/c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7/c38f489d712502ce57e5f6b86d8ad1efd3cf64d3c60ab3239bf34a727d0155b7-json.log",
        "Name": "/blissful_noether",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "5000/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5000"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "shareable",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                44,
                168
            ],
            "Isolation": "",
            "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": [
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/asound",
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/49e30cda4983fa70169660522eb0264adb6a86ba7714f051ceb7fe9ba2e6f921-init/diff:/var/lib/docker/overlay2/52cc6d89b46870d8613801fc85cb6f9fa38c0b37b07857de839acd4d001b5530/diff:/var/lib/docker/overlay2/e058a1965c0dff7fbaf1f2fbbe9dbbd491f273d3389c093a3aff1a2c928e305e/diff:/var/lib/docker/overlay2/ea09144ed7206c329c5dac727f9ddd3f346260a59b9e595916f17ee11c3b6d97/diff:/var/lib/docker/overlay2/53820238bb96c5ce804cc77ecbad212bcd3bf6d6a1ca5fdcc3f4d6f4e2349007/diff",
                "MergedDir": "/var/lib/docker/overlay2/49e30cda4983fa70169660522eb0264adb6a86ba7714f051ceb7fe9ba2e6f921/merged",
                "UpperDir": "/var/lib/docker/overlay2/49e30cda4983fa70169660522eb0264adb6a86ba7714f051ceb7fe9ba2e6f921/diff",
                "WorkDir": "/var/lib/docker/overlay2/49e30cda4983fa70169660522eb0264adb6a86ba7714f051ceb7fe9ba2e6f921/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "volume",
                "Name": "df1fe5e69c6437bd3e43d737b5cf7b37f9c1c5325b5505964579fd093ed4beae",
                "Source": "/var/lib/docker/volumes/df1fe5e69c6437bd3e43d737b5cf7b37f9c1c5325b5505964579fd093ed4beae/_data",
                "Destination": "/tmp",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            }
        ],
        "Config": {
            "Hostname": "c38f489d7125",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": true,
            "AttachStderr": true,
            "ExposedPorts": {
                "5000/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin",
                "LANG=C.UTF-8",
                "JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk",
                "JAVA_VERSION=8u212",
                "JAVA_ALPINE_VERSION=8.212.04-r0"
            ],
            "Cmd": null,
            "ArgsEscaped": true,
            "Image": "04d86c26964a",
            "Volumes": {
                "/tmp": {}
            },
            "WorkingDir": "",
            "Entrypoint": [
                "java",
                "-jar",
                "/app.jar"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "fb790b4e2c72fc9b2c9641e1eb91aca5e74759b2ee0265ce5a1907ddb3eb1865",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "5000/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5000"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/fb790b4e2c72",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "0f084ea8ca77ec70d850291644523b81597b761dabe687b4e0035b4ae2e3dd56",
            "Gateway": "xxx.xx.x.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "xxx.xx.x.x",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:bc:19:10:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "51b3be5f2161bb70042d5efd31f5b611cea241248a142f46fa612352c",
                    "EndpointID": "0f084ea8ca77ec70d850291644523b81597b761dabe687b45b4ae2e3dd56",
                    "Gateway": "xxx.xx.x.1",
                    "IPAddress": "xxx.xx.x.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:bc:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

我甚至才知道,即使是Docker容器也是由IP组成的。为什么会这样?有谁能帮助我理解容器是如何通过IP访问的吗?

我已经尝试了上面的JSON和ipconfig映像中所有可用的IP,但都不起作用。

共有1个答案

戴正阳
2023-03-14

是的,Docker容器有其唯一的IP地址(在Kubernetes中有更多)。

https://stackoverflow.com/A/43694284/9650284

有关说明(对解决方案的注释),请参阅本文。TLDR无法从主机访问docker容器的内部IP。

 类似资料:
  • 问题内容: 我在Windows 7上运行Tomcat 5.5实例(端口:8089)。 如果我打开http:// localhost:8089 / ,服务器将正常运行,但是在http://192.168.1.100:8089/上却给我一个错误(连接被拒绝) 我以为这是防火墙问题…所以我禁用了它,但是我仍然没有运气。 提前致谢。 解决了: 在连接器字符串中添加了 地址=“ 0.0.0.0” ,就可以了

  • 我已经检查了netstat并且能够找到处于侦听状态端口8080 C:\users\administrator>netstat-ano findstr“8080” TCP 0.0.0.0:8080 0.0.0.0:0侦听540 如有任何帮助,我们将不胜感激。谢谢你。

  • 我已经在本地机器上安装了Jenkins(ubuntu 19.10)。我可以使用或连接到Jenkins。但是,我无法使用我的公共ip地址连接到Jenkins!! 我试图通过以下方式解决这个问题: 修改。我修改HTTP_HOST为和 Jenkins档案中的JENKINS_ARGS是 JENKINS_ARGS=“--webroot=/var/cache/$NAME/war--httpPort=$HTTP

  • 我在MongoDB中配置了一个三节点副本集;复制是同步的。 我可以单独连接到每台服务器,并使用每台服务器的专用IP地址连接到副本集,如下所示: mongo—主机rs0/10。十、 X.X:27017,10。十、 X.X:27017,10。十、 X.X:27017-u根-p abc123-authenticationDatabase管理员 但是当我尝试使用服务器的公共IP地址连接到副本集时,如下所示

  • 问题内容: 我想知道Android设备的IP地址是数据IP还是Wifi IP。 1)首先将设备连接到3G,然后将设备分配给网络IP。 2)之后将设备连接到WIFI,现在该设备将分配给WIFI IP。 3)任何可以让我们知道IP地址是Wifi IP地址还是网络IP的Android API? 在2.3.5中使用了下面的代码,一切都很好,但是在4.0.3中,ICS存在一些问题。 请帮助 4)当我关闭移动

  • 我正在尝试将jboss绑定到一个外部ip地址,而不是默认的127.0.0.1,但是我得到了错误并且无法。 我要绑定到的IP地址是有效和可访问的,并且我已经使用ping进行了测试。我试过修改standalone.conf或修改standalone.xml,也试过-b xxx.xxx.236.237逼近,但每次都得到相同的错误。 请帮忙。多谢了。