So I have 3 ports that should be exposed to the machine's interface. Is it possible to do this with a Docker container?
相关问题
- 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
if you use
docker-compose.yml
file:You can also specify the host/network port
To expose just one port, this is what you need to do:
To expose multiple ports, simply provide multiple
-p
arguments:Step1
In your
Dockerfile
, you can use the verbEXPOSE
to expose multiple ports.e.g.
Step2
You then would like to build an new image based on above
Dockerfile
.e.g.
Step3
Then you can use the
-p
to map host port with the container port, as defined in aboveEXPOSE
ofDockerfile
.e.g.
In case you would like to expose a range of continuous ports, you can run docker like this: