Reputation: 161
This is my docker-compose file, I cannot connect to the database
version: "3.9"
services:
mongodb:
image: mongo:5.0.2
container_name: armaghan_db
restart: unless-stopped
networks:
- armaghan-network
ports:
- 27017:27017
volumes:
- db:/data/db
backend:
container_name: armaghan_backend
depends_on:
- mongodb
build:
context: .
dockerfile: "Dockerfile"
ports:
- "5001:5000"
networks:
- armaghan-network
restart: unless-stopped
environment:
PORT: 5000
armaghan_jwtPrivateKey: privatekeyarmaghansoroushmadani
armaghan_db: mongodb://localhost:27017/armaghan
stdin_open: true
tty: true
volumes:
db:
networks:
armaghan-network:
driver: bridge
the mongodb image is running, I can make a connection to it when I run the application without docker. but connection fails inside docker.
Upvotes: 0
Views: 3180