Docker 公开从 7000 到 8000 的所有端口或端口范围 [英] Docker expose all ports or range of ports from 7000 to 8000

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

问题描述

我可以在 Dockerfile 中指定端口范围吗

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

推荐答案

从 Docker 1.5 开始,您现在可以使用:

Since Docker 1.5 you can now expose a range of ports to other linked containers using:

Dockerfile EXPOSE 命令:

The Dockerfile EXPOSE command:

EXPOSE 7000-8000

或 Docker run 命令:

or The Docker run command:

docker run --expose=7000-8000

或者,您可以通过 Docker 发布一系列端口到主机="noreferrer">运行命令:

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天全站免登陆