Caveat # 1: I've read this answer, this answer, and a miriad other answers/posts and I still can't get it to work.
Caveat # 2: I'm new to docker, so I'm probably missing something really simple.
I'm running Docker on Windows, and have this ELK image running which I launched with this command:
sudo docker run -p 5601:5601 -p 9200:9200 -p 5000:5000 -it --name elk sebp/elk
I'm trying to access ports 5601
and 9200
from a browser running on Windows, and I keep getting a connection timeout. Here's what I've done:
- I believe the
docker run
command (above) is forwarding ports 5601 and 9200 from the container to the docker host (boot2docker VM) already, so that should be fine.
- I got the elk docker container IP by running
docker inspect $(docker ps -q) | grep IPA
on the docker CLI. This turned out to be 172.17.0.9
. I then ran curl 172.17.0.9:5601
and curl 172.17.0.9:9200
. I was able to get proper HTML responses from those URLs. This allowed me to verify things were running properly in the docker container/host.
- Then I got the docker host's IP by running
docker-machine ip default
. This turned out to be 192.168.99.100. I believe this is all I need to access the elk container from the docker host (Windows in this case), since port forwarding for the container was already set. With that IP, I tried going to http://192.168.99.100:5601
and http://192.168.99.100:9200
and I get ERR_CONNECTION_TIMED_OUT
. I also tried using IE, and even https
for kicks, and still no luck.
- I also tried pinging
192.168.99.100
from DOS, but was unable to get a response. I tried relaxing the firewall rules in Windows (just for kicks again) and I got nothing.
What am I missing?
actually in windows there will be a Ubuntu VM will be running, on top of that only your containers are hosted so only you won't be able to access it directly
Even i faced that same problem and i followed the below steps to solve my problem
1. Enabled routing as told in the above post
2. Added a port forwarding from windows host to Ubuntu host where the containers are hosted by using below command
netsh interface portproxy add v4tov4 listenport=4422 listenaddress=192.168.1.111 connectport=3128 connectaddress=192.168.0.33
a. Here 192.168.1.111 is my windows host ip address and 4422 is the port to where other machines in same network will call
b. Here 192.168.0.33 is the ubuntu host where containers are hosted and 3128 is the ubuntu host port which is mapped to the container
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
090af3e0c7a4 sameersbn/squid:3.3.8-5 "/sbin/entrypoint.sh" 6 hours ag
o Up 5 hours 0.0.0.0:3128->3239/tcp squid
3. Then I added firewall to unblock inbound and outbound traffic for 4422 port in my windows host
Now I was able to access the container from any system in the network :)
If you are using a browser on the same docker machine, you should be able to access 127.0.0.1:
http://127.0.0.1:5601
http://127.0.0.1:9200
If you use a browser from another machine and try to access http://192.168.99.100:5601 and http://192.168.99.100:9200, you should enable routing on the Windows machine where docker is running.
Go to Start and search on cmd or command. Right click on either cmd or command then select Run as administrator. At the command prompt type regedit. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\Tcpip\Parameters\IPEnableRouter setting, right click and select Modify. Change 0 to 1 and exit the editor.
When your back at the command prompt type services.msc and navigate to the Routing and Remote Access service. Right click and select Properties. Change to Automatic and click on Start to start the service. Check out http://answers.microsoft.com/en-us/windows/forum/windows_7-networking/how-to-enable-ip-routing-in-windows-7/8970e722-e947-460d-80d5-fd6ffc850f3f?auth=1