0
I started using Docker a short time ago, probably why I got stuck in this problem.
I have a API and a Front who keeps making requests via Curl for her.
But when I put these projects on Docker and separated them into containers (to "simulate" the actual situation, since the API and the Front are on separate servers) requests Curl stopped working.
I did other tests and I couldn’t do the Curl work between containers. Follow image of example:
Docker used to create the two containers.
In the above test the following Docker-Compose was used (as shown in the next image the only difference between the two containers and the Docker-Compose is the port and container names):
a:
environment:
TZ: "America/Sao_Paulo"
image: o2multi/apache-php7
ports:
- "80:80"
volumes:
- ./src:/var/www/html/
If I try to make Curl to other places it works perfectly.
How do I make it work between containers?
Attempts made ----------------
version: '2'
services:
a:
environment:
TZ: "America/Sao_Paulo"
image: o2multi/apache-php7
ports:
- "80:80"
volumes:
- ./a:/var/www/html/
links:
- b
b:
environment:
TZ: "America/Sao_Paulo"
image: o2multi/apache-php7
ports:
- "443:80"
volumes:
- ./b:/var/www/html/
I had uploaded the separate containers each with a Docker-Compose. I did what you suggested, created a Docker-Compose with the two containers and used the links to link the front to the back but the error persists. The link worked because if I try to make a request from the back to the front it is loading too much time and from the timeout, if I do from front to back it does not return error. But it does not return the data either.
– Etobdc
You will need to expose your doors on the back and on the front... But why are you trying to make a call on the back to the front
– KhaosDoctor
I was just testing to see if the link between the containers had actually worked. I exposed the ports but tbm didn’t work.
– Etobdc