【问题标题】:get the IP adress to use for a docker container on a network获取用于网络上 docker 容器的 IP 地址
【发布时间】:2020-09-01 03:09:32
【问题描述】:

我的 NAS 是我运行容器的地方。它位于我网络上的192.168.1.23。

我正在用户定义的网络中运行一些容器。这是docker network inspect(我已经手动删除了容器):

[
    {
        "Name": "traefik2_proxy",
        "Id": "fb2924fe59fbb0436c72f11cb028df832a473a165162ecf08b7e3a946cfa2d3c",
        "Created": "2020-05-13T23:23:16.16424119+08:00",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "192.168.90.0/24",
                    "Gateway": "192.168.90.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]

我在该网络中有一个特定的容器,该容器的 IP 地址为 192.168.90.16,我在 docker-compose 中使用以下内容公开了 9118 端口:

ports:
  - target: 9118
    published: 9118
    protocol: tcp

这是搬运工的截图:

我希望能够使用 192.168.1.23:9118 连接到该容器,但我尝试无济于事。

我错过了什么?我需要更改哪个设置才能使该容器在我的 NAS IP 地址上的该端口可见?

【问题讨论】:

  • 192.168.1.23上绑定的端口是什么?
  • 不确定我是否理解这个问题。 192.168.1.23 位于我的 LAN 上,所以我没有在端口上设置任何内容。
  • 所以我猜没有绑定端口
  • 192.168.90.16:9118 看起来暴露了没有 1.23 ?在您的问题中,您能提供更多详细信息吗?
  • 修复了吗?或者您似乎必须通过 traefik 公开

标签: docker docker-compose docker-networking docker-network


【解决方案1】:

容器监听的端口不正确。我需要将ports 配置修改为:

ports: 
  - target: 9117 
    published: 9118 
    protocol: tcp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-01
    • 2021-04-17
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 2021-01-14
    • 2016-11-02
    • 1970-01-01
    相关资源
    最近更新 更多