S
S
sv82019-08-17 17:07:19
System administration
sv8, 2019-08-17 17:07:19

How to access another docker container from one docker container?

Hello!
There are 2 separate projects locally deployed on the PC:
- frontend - where docker-compose consists of a single node-container;
- backend - there docker-compose consists of 3 containers (we will be interested only in nginx on port 88) ;
As I understand it, each project (docker-compose.yml) eventually creates its own network (network) - in the picture below I have shown how it looks (if I understand everything correctly).
What is the problem:
1. From the browser I knock on localhost:3000
2. The request successfully reaches node.js (I see it in the logs)
3. Next, node.js pulls the container with the API - it accesses http://172.18.160.225:88 *
4. ... and on this request falls off by timeout.
* - if I access this address from the browser - there will be no timeout.
As a result, it turns out that I have 2 neighboring docker networks deployed locally, and from one I cannot reach the second. But the task seems to be trivial.
People who know, tell me, please, what is the problem and how to solve this problem?
5d5807b0c242c726626824.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
1001001, 2019-08-17
@1001001

Specify a specific network for containers via networks:
and contact not via ip but via the name nginx:88 or whatever it is called
https://docs.docker.com/compose/networking/

V
Vitaly Karasik, 2019-08-17
@vitaly_il1

Wouldn't it be easier to combine the backend and frontend in one docker-compose?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question