wangduanduan / wangduanduan.github.io

Wubba Lubba dub-dub
https://wdd.js.org
27 stars 7 forks source link

暴露指定范围的端口 #322

Closed wangduanduan closed 2 years ago

wangduanduan commented 5 years ago
Since Docker 1.5 you can now expose a range of ports to other linked containers using:

The Dockerfile EXPOSE command:

EXPOSE 7000-8000

or The Docker run command:

docker run --expose=7000-8000

Or instead you can publish a range of ports to the host machine via Docker run command:

docker run -p 7000-8000:7000-8000

https://stackoverflow.com/questions/28717464/docker-expose-all-ports-or-range-of-ports-from-7000-to-8000

wangduanduan commented 5 years ago

docker run -p hostPort:containerPort

冒号前是宿主机端口,冒号后是容器端口