Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for publishing ranges of ports #8899

Closed
md5 opened this issue Nov 1, 2014 · 13 comments · Fixed by #9097
Closed

Add support for publishing ranges of ports #8899

md5 opened this issue Nov 1, 2014 · 13 comments · Fixed by #9097

Comments

@md5
Copy link
Contributor

md5 commented Nov 1, 2014

Given the ability to --expose ranges of ports from #8167, it would be useful to be able to publish ranges of ports as well. I'd like to be able to do this:

docker run -d --publish 10000-20000:10000-20000 myimage
@kfei
Copy link

kfei commented Nov 20, 2014

👍

@cv711
Copy link

cv711 commented Dec 12, 2014

Can we please merge this one? It's quite useful. Thanks!

brahmaroutu pushed a commit to brahmaroutu/docker that referenced this issue Jan 2, 2015
Closes moby#8899
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
@krasi-georgiev
Copy link
Contributor

docker run -help doesn't show the new option for port range

-p, --publish=[] Publish a container's port to the host
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
(use 'docker port' to see the actual mapping)

@krasi-georgiev
Copy link
Contributor

one more bug
http://screencast.com/t/h3KuExeJr8Nj

on every port it ads new line so docker ps becomes unreadable.

@thaJeztah
Copy link
Member

@vipconsult I think the output of ps is being worked on here; #10339

@ColmHally
Copy link
Contributor

@vipconsult @thaJeztah yeah, I'll be adding published ranges in ps output later tonight on #10339

@dkirrane
Copy link

Are there any limits on port ranges?
I'm publishing approx. 200 ports
docker run -p 7000-7200 -p 8080 webservice

If I exec into the container I can curl to the webservice URL:
curl http://localhost:8080/my/web/service

But if I do same from the host ip it just gets stuck loading the page:
curl http://HOST_IP:8080/my/web/service

@thaJeztah
Copy link
Member

@dkirrane is your webservice perhaps only listening on localhost? It should be listening on "any" IP-address (ie, 0.0.0.0)

@md5
Copy link
Contributor Author

md5 commented Feb 25, 2015

@dkirrane your service's ports are being published on random host ports.

Try this:

docker run -p 7000-7200:7000-7200 -p 8080:8080 webservice

@md5
Copy link
Contributor Author

md5 commented Feb 25, 2015

Be aware that starting a container with a large published range of ports like that is currently quite slow. I didn't dig into it, but I'm assuming the reason is that Docker is creating individual iptables rules for each port in the range instead of taking advantage of iptables's native ability to map port ranges.

@thaJeztah
Copy link
Member

service's ports are being published on random host ports

^^ oh, correct, wasn't paying attention

@dkirrane
Copy link

@md5 Ya sorry that was a typo. I've reduced the number of ports & mapped the port-range as described:
docker run -d -p 7000-7003:7000-7003 -p 7053-7063:7053-7063 -p 8099:8099 -p 9080:9080 -p 9443:9443 --name="my-service" dkirrane/my-service

Now from the host machine if I curl to my docker service using localhost the page returns. However, when I use the Host IP curl fails

alias hostip="ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"

# Localhost works
curl http://localhost:9080/my/web/service

# Host IP returns connection timesout
curl http://$(hostip):9080/my/web/service

@md5
Copy link
Contributor Author

md5 commented Feb 26, 2015

I'm not sure why you're using that method to get your host IP address, but I think you're getting the wrong IP to pick up the port mapping. That command is giving you your outbound gateway address for the default route, not the host IP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants