How to forward all ports in a docker container

Consider:

docker run -p 5000:5000 -v /host/:/host appimage 

he forwards from 5,000 to 50,000

even in a few:

 docker run -p 5000:5000 -p 5001:5001 -v /host/:/host appimage 

What I want to know:

 docker run -p allports:allports 

Is there any command to forward all ports in the container? Because in my case, I am running a flask application. For testing purposes, I want to run several instances of jars. Therefore, for each instance of the flag, I want to run it in different ports. This automatic multi-port forwarding will help.

+5
source share
2 answers

You can have a working setup using docker run --net host ... , in which case the host network is directly exposed to the continent, and all port bindings are "publicly available". I have not tested this with multiple containers at the same time, but it may work fine.

+1
source

You can open a range of ports using the -p option, for example:

 docker run -p 2000-5000:2000-5000 -v /host/:/host appimage 

See the docker run help documentation for more details.

0
source

Source: https://habr.com/ru/post/1235894/


All Articles