❔ "Cannot assign requested address [::1]:27017" when connecting to MongoDB on Docker.
I have a Docker Compose file with containers
backend:
image: home-api
ports:
I recieve an error from the backend container. (attached)
New to MongoDB, Docker, and ASP.NET. Let me know if you want any additional information.
backend: ASP.NET Core web APImongo: MongoDB
which looks like this:
```
version: '3.4'
backend:
image: home-api
ports:
- "2154:2154"build:context: ./apidockerfile: ./api/Dockerfilemongo:image: mongorestart: alwaysports:
- "2155:27017"
volumes: - ./Data:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: home-api
MONGO_INITDB_ROOT_PASSWORD: home-api`` With the API, I followed two tutorials: - https://learn.microsoft.com/en-us/aspnet/core/web-api/?WT.mc_id=dotnet-35129-website&view=aspnetcore-7.0 - https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mongo-app?view=aspnetcore-7.0&tabs=visual-studio-code I then containerized it and startedmongodin a./Data` directory.
appsettings.jsonI recieve an error from the backend container. (attached)
New to MongoDB, Docker, and ASP.NET. Let me know if you want any additional information.
error.txt6.35KB
This tutorial demonstrates how to create an ASP.NET Core web API using a MongoDB NoSQL database.
