Reputation: 486
I'm using two different docker-compose setup for two different projects. I need to make an HTTP request from one to other and tried to send it like http://localhost:8050/api
but keep getting cURL error even though it is working on Postman. Here are the docker-compose files:
File 1 (Request receiver)
version: '3'
services:
app:
container_name: core
build: .cloud/php
image: app-core
ports:
- "9050:9000"
volumes:
- ./:/var/www:cached
networks:
- core_network
nginx:
container_name: core.nginx
image: nginx
ports:
- "8050:8000"
volumes:
- .cloud/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:cached
- ./:/var/www:cached
depends_on:
- app
networks:
- core_network
pgres:
container_name: core.postgres
image: postgres
restart: always
ports:
- "54321:5432"
environment:
POSTGRES_DB: sampleuser
POSTGRES_USER: postgres
POSTGRES_PASSWORD: example
volumes:
- .cloud/postgres/data:/var/lib/postgresql/data
networks:
- core_network
networks:
core_network:
driver: bridge
File 2 (Request sender)
version: '3'
services:
app:
container_name: b2c
build: .cloud/php
image: app-b2c
ports:
- "9055:9000"
volumes:
- ./:/var/www:cached
networks:
- b2c_network
nginx:
container_name: b2c.nginx
image: nginx
ports:
- "8055:8000"
volumes:
- .cloud/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:cached
- ./:/var/www:cached
depends_on:
- app
networks:
- b2c_network
networks:
b2c_network:
driver: bridge
Upvotes: 2
Views: 2338
Reputation: 486
For anyone struggling you can make requests like: http://host.docker.internal:8050
Upvotes: 11