Docker将所有端口或端口范围从7000暴露到8000 [英] Docker expose all ports or range of ports from 7000 to 8000

查看:2675
本文介绍了Docker将所有端口或端口范围从7000暴露到8000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在Dockerfile中指定端口范围

  EXPOSE 7000-8000 

当运行容器将所有这些暴露端口绑定到主机上的相同端口?

  docker run -p 7000-8000:7000-8000 


一系列端口公开到其他链接的容器:



Dockerfile EXPOSE 命令:



EXPOSE 7000-8000



或Docker 运行命令:



docker run --expose = 7000-8000



或者您可以通过Docker run 命令:



docker run -p 7000-8000:7000-8000


Can I specify a port range in a Dockerfile

EXPOSE 7000-8000

and when running the container bind all these exposed ports to the same ports on the host machine?

docker run -p 7000-8000:7000-8000

解决方案

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

这篇关于Docker将所有端口或端口范围从7000暴露到8000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆