问题
I have created two docker networks
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
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