简体   繁体   English

获取 IP 地址以用于网络上的 docker 容器

[英]get the IP adress to use for a docker container on a network

My NAS is where I run my containers.我的 NAS 是我运行容器的地方。 It sits on 192.168.1.23 on my network.它位于我网络上的192.168.1.23上。

I am running a few containers inside a user-defined network.我在用户定义的网络中运行一些容器。 Here is the docker network inspect (I've removed the containers manually):这是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": {}
    }
]

I have a specific container which is in that network at IP address 192.168.90.16 for which I have exposed the 9118 port using the following in my docker-compose:我在 IP 地址192.168.90.16的网络中有一个特定的容器,我在 docker-compose 中使用以下内容公开了9118端口:

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

This is the portainer screenshot:这是搬运工屏幕截图:

在此处输入图像描述

I was expecting to be able to connect to that container using 192.168.1.23:9118 but I tried to no avail.我希望能够使用192.168.1.23:9118连接到该容器,但我尝试无济于事。

What am I missing?我错过了什么? Which setting do I need to change for that container to be visible at that port on my NAS IP address?我需要更改哪个设置才能使该容器在我的 NAS IP 地址上的该端口可见?

The port that the container was listening to was incorrect.容器监听的端口不正确。 I needed to modify the ports configuration to:我需要将ports配置修改为:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 ansible 过滤 ip docker 容器的地址 - filter ip adress of docker container via ansible 使用Docker容器的静态IP在另一个网络上运行Web应用程序 - Use static IP for Docker container to run web app on another network 在主机网络上使用docker容器而不共享主机的IP - use docker container on host network without sharing host's ip 具有多个网络接口的Docker容器:只获取一个IP地址 - Docker container with multiple network interfaces: get only one IP address Docker compose为每个网络添加本地ip地址 - Docker compose add local ip adress per network 如果docker容器ip和外部网络ip相同,那么如果执行telnet,则哪个响应? 任何想法 - If docker container ip and external network ip is same, then which one will get respond if will do telnet? any idea 如何将docker容器ip暴露给外网? - How to expose the docker container ip to the external network? 为什么我必须定期使用 `docker network prune` 来重新启用容器内的 docker 映射 ip 连接? - Why do I have to periodically use `docker network prune` to reenable docker mapping ip connections inside a container? 在自定义网络中访问Docker容器的IP地址 - Accessing IP address of a docker container in a custom network 使用容器docker作为CF应用的代理获取公网IP - Use of container docker as a proxy for CF app to get public IP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM