Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose container ports not working

I'm running a container that's initiated by docker-container like so:

  puppetboard:
    build: ./images/puppetboard
    image: puppet/puppetboard
    ports:
      - 5000:5000
    links:
      - puppetdb:puppetdb

It successfully builds and when I run docker ps I can see:

0.0.0.0:5000->5000/tcp

I can even go into the container using docker exec and use curl localhost:5000 which returns an html page.

I double check that host machine can see port 5000 on 127.0.0.2 (docker network) with nmap 127.0.0.2 and the port is available: 5000/tcp open upnp.

Yet when I go to 127.0.0.2:5000 in my browser on the host machine I get website not available. How can I debug this network issue?

Result of curl 127.0.0.2:5000 & curl 127.0.0.1:5000 is: curl: (56) Recv failure: Connection reset by peer.

like image 727
Philip Kirkbride Avatar asked Dec 11 '22 11:12

Philip Kirkbride


2 Answers

127.0.0.x is a loopback address. For publishing ports in the container to the host, you need to listen on all interfaces in the container. So you'll need to make sure your app inside the container is configured to listen on 0.0.0.0:5000 (this is different from the option publishing the port in the docker compose file).

like image 177
BMitch Avatar answered Mar 16 '23 01:03

BMitch


As we discuss it in this room, you have to ensure that the containerized application listen on all interfaces inside the container. In the puppet board case, config looks like :

DEV_LISTEN_HOST = '0.0.0.0' 

0.0.0.0 is used to say "all interfaces"

like image 21
papey Avatar answered Mar 16 '23 01:03

papey