Docker expose all ports or range of ports from 700

2019-01-17 09:15发布

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

1条回答
可以哭但决不认输i
2楼-- · 2019-01-17 09:56

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

查看更多
登录 后发表回答