所有码头网络的端口不常用? [英] is port not common for all the docker networks?
问题描述
我创建了两个码头网络
-
chnetwork
chnetwork
docker network create --subnet=172.19.0.0/16 chnetwork
内部网络
Internal-network
docker network create --internal --subnet 10.1.1.0/24 internal-network
同时创建docker容器我使用 chnetwork ,
while create docker container I use chnetwork,
docker run -it -d --name containerone -h www.cone.net -v /var/www/html -p 3006:80 --net chnetwork --ip 172.19.0.40 --privileged magento
稍后我更改为内部网络并从 chnetwork 断开容器
later I have changed to Internal-network and disconnect container from chnetwork
docker network connect internal-network containerone
docker network disconnect chnetwork containerone
现在的问题是 docker ps 命令不显示该con的端口当我将网络更改为 chnetwork 时,在内部网络中
now the problem is docker ps command does not display port of that container, I mean port is not accessible in internal-network.
只有 docker ps 显示端口。在Docker网络中可以访问我需要做什么的端口?
when I change network to chnetwork that time only docker ps display ports. what I need to do for port is accessible in all the docker networks?
推荐答案
这似乎是内部网络的行为。由于连接到容器的唯一网络是不允许外部流量的内部网络,因此容器被设计隔离。要发布端口,您需要将容器连接到非内部桥接网络。一旦将非内部桥接网络连接到容器,您将看到已发布的端口重新出现。
This appears to be the behavior of internal networking. Since the only network attached to the container is an internal network which doesn't permit external traffic, the container becomes isolated by design. To publish a port, you need the container to be attached to a non-internal bridged network. And as soon as you connect a non-internal bridged network to the container, you will see the published port reappear.
这篇关于所有码头网络的端口不常用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!