Since Docker 1.5 you can now expose a range of ports to other linked containers using:
The Dockerfile command:
EXPOSE 7000-8000
or The Docker command:
docker run --expose=7000-8000
Or instead you can publish a range of ports to the host machine via Docker command:
docker run -p 7000-8000:7000-8000
以上只是声明要导出的端口,
这样写就可以直接导出
docker run -it --privileged --name e1 -p 7000-7010:7000-7010/tcp <镜像id> /bin/bash
在主机里执行 netstat -aon |grep 700 可以看到
tcp6 0 0 :::7000 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7001 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7002 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7003 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7004 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7005 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7006 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7007 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7008 :::* LISTEN off (0.00/0/0)tcp6 0 0 :::7009 :::* LISTEN off (0.00/0/0)