I'm trying to connect a ASP.NET Core container to PostgreSQL official container using Docker-Compose, I've name my container as aspnetcore-postgres
and it contains in the configuration the connection string points to the PostgreSQL container as:
User ID=postgres;Password=5432;Host=localhost;Server=localhost;Port=5432;Database=ApplicationDbContext;Pooling=true;
And I use the following compose file for connection:
version: '2'
services:
web:
image: aspnetcore-postgres
ports:
- "5000:5000"
networks:
- aspnetcoreapp-network
postgres:
image: postgres
environment:
- "POSTGRES_PASSWORD: 5432"
networks:
- aspnetcoreapp-network
ports:
- "5432:5432"
networks:
aspnetcoreapp-network:
driver: bridge
Whenever I try to run docker-compose up
, the web application can't recognize the database container. Eventually, I only see the Postgres container in the network not the web application container. I'm using Docker for Windows RC4.
Anyone can recognized that where I'm doing the wrong step?