is port not common for all the docker networks?

2019-07-14 01:56发布

I have created two docker networks

  1. chnetwork

     docker network create --subnet=172.19.0.0/16 chnetwork
    
  2. Internal-network

     docker network  create --internal --subnet 10.1.1.0/24 internal-network
    

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

later I have changed to Internal-network and disconnect container from chnetwork

docker network connect internal-network containerone
docker network disconnect chnetwork containerone

now the problem is docker ps command does not display port of that container, I mean port is not accessible in internal-network.

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?

1条回答
ら.Afraid
2楼-- · 2019-07-14 01:58

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.

查看更多
登录 后发表回答