I understand that to expose ports in a docker container, you can use the -p
flag (e.g. -p 1-100:1-100
). But is there a nice way to expose a large percentage of possible ports from the container to the host machine? For instance if I am running a router of sorts in a container that lives in a VM, and I would like to expose all ports in the container from 32768 upwards to 65535, is there a nice way to do this? As it stands I've tried using the -p
flag and it complains about memory allocation errors.
相关问题
- Docker task in Azure devops won't accept "$(pw
- Unable to run mariadb when mount volume
- Unspecified error (0x80004005) while running a Doc
- What would prevent code running in a Docker contai
- How to reload apache in php-apache docker containe
tl;dr
Docker offers different networking modes for containers. By default the networking mode is
bridge
which implies the need to expose ports.If you run a container with networking mode
host
then you won't need to expose/forward ports as both the docker host and the container will share the very same network interface.In the container,
localhost
will refer to the docker host. Any port opened in the container is in fact opened on the docker host network interface.Nvm. I figured out my misunderstanding.
-P
is what I want, and I want to expose and not explicitly map ports.