Answer the question
In order to leave comments, you need to log in
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?
Answer the question
In order to leave comments, you need to log in
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/
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 questionAsk a Question
731 491 924 answers to any question