0

I have a docker-compose file with 3 services like the following

service:
service1-dev:
(filled with the good config)
network : 
 custom_network
 ipv4_address:167.34.0.5
service2-test:
(filled with the good config)
network : 
 custom_network
 ipv4_address:167.34.0.3
service3-request:
(filled with the good config)
network : 
 custom_network
 ipv4_address:167.34.0.2

networks:
custom_network:
driver: bridge
ipam:
  config:
    - subnet: 167.34.0.0/16

Everything work fine and my service1-dev is running on 0.0.0.0:8081 When my dev container is running i can easily acces it with the following in a browser : http://localhost:8081/test and im receiving my json

The probleme is im running my service3-request that should send some request to my service1-dev but the request are not working.

I don't understand why isn't working both of my container are in the same network 167.34.0.0/16 they both can ping eachother but im trying to do a : curl http://localhost:8081/test error 502

OR

curl http://167.34.0.5:8081/test do nothing

but it doesnt work.

So i don't understand how i can ping all my container but i cannot receive my json when i call my service

guillaume
  • 41
  • 5

2 Answers2

0

Do you have access to some log file to check that 502 error.

Something comes to mind, run netstat -tanp | grep LISTEN

This should give you something like that, where :::* means that anyone can connect to that port.

tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      2868/cupsd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      3568/master
tcp        0      0 :::42266                    :::*                        LISTEN      2794/rpc.statd
tcp        0      0 :::10080                    :::*                        LISTEN      25226/java

As per our discussion - it is possible that flask is made that way for security reasons. In this way you should install local web server and configure it to server your flask app. Mind you that this is the preferable way to run apps in production!

I would recommend nginx as it is free, very light, super fast and very easy to setup. https://nginx.org/

And btw read on that topic here: What does "app.run(host='0.0.0.0') " mean in Flask

Deian
  • 1,237
  • 15
  • 31
  • i did the command and im having this result `tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN 1/python` – guillaume Oct 04 '18 at 20:18
  • Look at the last line in my example - this is now it should look to be seen from outside – Deian Oct 04 '18 at 20:22
  • Im not sure how to achieve your result. My service1-dev is an flask app and when i run the flask app i run it like this `app.run(host='0.0.0.0', port=8081)` with this it should make it public ? – guillaume Oct 04 '18 at 20:39
  • host='0.0.0.0' is this a param you can change? try '*' – Deian Oct 04 '18 at 22:08
  • I try but doesn't work is not a valid param.(i cannot even start my service1-dev) I did read some doc about flask app to have it public i did try what they said in the doc but still doesn't work. It running but i cannot reach it. – guillaume Oct 05 '18 at 12:10
0

Well all have to do is to unset my proxy and use the container name in my request curl http://service1-dev:8081/test

Everything work perflectly now !

guillaume
  • 41
  • 5