is port not common for all the docker networks?

依然范特西╮ 提交于 2019-12-11 03:46:20

问题


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:


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.



来源:https://stackoverflow.com/questions/40059375/is-port-not-common-for-all-the-docker-networks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!