I want to access service1 from inside of service2 container by using localhost:5432
. How can do so?
This is what my docker compose currently looks like:
services:
service1:
image: postgres:12
ports:
- '172.10.1.1:5432:5432'
expose:
- '5432'
environment:
- POSTGRES_USER=project
- POSTGRES_PASSWORD=pass
volumes:
- db_data:/var/lib/postgresql/data
service2:
build: .
ports:
- '172.10.1.1:1234:1234'
Please note I know i can access it by using service1:5432
or just service1
. But I would like to use localhost
if possible.