In my job I working with docker and the option --net=host
working like a charm forwarding the docker container ports to the machine. This allows me to adding gr
One workaround, mentioned in "Bind container ports to the host" would be to use -P
:
(or
--publish-all=true|false
) to docker run which is a blanket operation that identifies every port with anEXPOSE
line in the image’s Dockerfile or--expose
commandline flag and maps it to a host port somewhere within an ephemeral port range.
The docker port command then needs to be used to inspect created mapping.
So if your app can use docker port
to retrieve the mapped port, you can add as many containers as you want and get the mapped ports that way (without needed an "explicit -p
command for each port").