Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

First: could someone with 300 rep make a tag for "docker" please? TYVM

I'm running a docker container for elasticsearch with the following command:

docker run -d -i -t -p 9200:9200 -p 9300:9300 elasticsearch:0.90.5

Which launches correctly and when I curl localhost:9200 I get the elasticsearch json hello world message.

What I can't figure out is how to get the ports to be exposed outside the box. What I am trying to do is:

docker run -d -i -t -p 123.123.123.123:9200:9200 -p 123.123.123.123:9300:9300 elasticsearch:0.90.5

where 123.123.123.123 is the eth0 IP address. That does not seem to work.

And now my question: How do I properly run this container and expose these ports to the outside world?

Here is my "ip addr" from the box which is a headless vmware running ubuntu 12.04.

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:52:56:93:78:f6 brd ff:ff:ff:ff:ff:ff
    inet 162.248.XXX.XXX/24 brd 162.248.XXX.255 scope global eth0
    inet6 XXX::250:ab00:fe89:78f6/64 scope link 
       valid_lft forever preferred_lft forever
3: lxcbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN 
    link/ether 72:44:60:e8:46:2a brd ff:ff:ff:ff:ff:ff
    inet 10.0.3.1/24 brd 10.0.3.255 scope global lxcbr0
    inet6 XXX::7080:60ff:fee8:462a/64 scope link 
       valid_lft forever preferred_lft forever
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP 
    link/ether ba:d6:67:1a:13:bc brd ff:ff:ff:ff:ff:ff
    inet 172.17.42.1/16 scope global docker0
    inet6 XXX::549c:ebff:fe7d:a22/64 scope link 
       valid_lft forever preferred_lft forever
210: vethgVxkby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master docker0 state UP qlen 1000
    link/ether ba:d6:67:1a:13:bc brd ff:ff:ff:ff:ff:ff
    inet6 XXX::b8d6:67ff:fe1a:13bc/64 scope link 
       valid_lft forever preferred_lft forever
share|improve this question

2 Answers 2

Docker might support networking in the future. But for now you can you Pipework to manage Docker network like this (Host only).

sudo pipework br1 $(docker run -d -i -t elasticsearch:0.90.5) 192.168.2.1/24
sudo ip addr add 192.168.2.254/24 dev br1

But if you want it to be public IP address x.x.x.x (ubiquitous):

pipework eth0 $(docker run -d -i -t elasticsearch:0.90.5) x.x.x.x
share|improve this answer
    
Docker has had network support since March blog.docker.io/2013/03/docker-containers-can-haz-networking-now –  Kevin Dec 10 '13 at 22:00

I thought that running it like you did at first docker run -d -i -t -p 9200:9200 -p 9300:9300 elasticsearch:0.90.5 should work. Maybe you also have a firewall interfering?

Can you try to run a normal server (ideally elasticsearch without docker, because the elasticsearch config could be a problem too) on port 9200 or whatever first and make sure you can connect to that? And once thats working I think the original command should work.

Maybe try sudo ufw allow 9200 or something?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.