简体   繁体   中英

prevent Docker from exposing port on host

If i start a container using -p 80 for example, docker will assign a random outbound port.

Everytime Docker assign a port, it also add an iptable rule to open this port to the world, is it possible to prevent this behaviour ?

Note : I am using a nginx load balancer to get the content, I really don't need to have my application associated with two different port.

You can specify both interface and port as follows:

-p ip:hostPort:containerPort

or

-p ip::containerPort

Another solution is to run nginx inside container and to use conteiner linking without exposing other services whatsoever.

The iptable feature is a startup parameter for the docker demon. Look for the docker demon conf file in your docker installation. Add --iptables=false and docker never touches your iptables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM