0

I have created a docker image which runs kafka inside the container. I have also done port mappings in the docker-compose.yml for mapping the host ports with container ports.

After bringing up the docker image (using docker-compose), I am able to see that the docker image is up and running and a container is also started as shown below:

e39cd6452307        dockerregistry:5000/confluent:latest   "/run.sh"              10 hours ago        Up 10 hours         0.0.0.0:8081->8081/tcp, 0.0.0.0:2108->2181/tcp, 0.0.0.0:9920->9092/tcp   confluent

'ps-ef | grep docker' also provides me the following result:

root      6594  5257  0 Jan17 ?        00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 9920 -container-ip 172.17.0.1 -container-port 9092
root      6605  5257  0 Jan17 ?        00:00:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8081 -container-ip 172.17.0.1 -container-port 8081
root      6617  5257  0 Jan17 ?        00:04:22 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 2108 -container-ip 172.17.0.1 -container-port 2181

Weird thing starts here:

If I try to connect to service running inside the container from my host machine by using container IP and port (IP: 172.17.0.1, Port: 2181), my connection is successful and I get proper response.

However, If I try to connect to the service from host machine using the mapped host IP and port(using 10.xx.xx.xx:2108), I get a connection refused message. (xx is just used for masking my machine ip)

Also, 'telnet 10.xx.xx.xx 2108' works fine.

What could be the problem in this case. I have docker version 1.7.1 and docker-compose version 1.5.0

Please help.

Amandeep Singh
  • 297
  • 4
  • 19

2 Answers2

1

As i can see that it is working fine inside the container using container ip and port ,that points to

docker-compose

file , may be port mapping is not done there properly.

Could you please upload your docker-compose because the only issue is of port as it is not exposed properly. Also you can check in your docker run command if the

-p port:port

is actually the port you want to expose or not.

emme
  • 215
  • 1
  • 8
0

I had the same problem and was able to fix it by specifying the host that the server within the container uses. See my answer here: Access Docker forwarded port on Mac

Community
  • 1
  • 1
mepler
  • 907
  • 8
  • 12