I have a Spring Boot Application and developed it with a mongo db which was running in brew services.
To get a connection to the db I just had to put the following
Try the following docker-compose.yml
. hostname
should fix your problem
version: '3'
services:
mongo:
container_name: docker-mongo
image: mongo:latest
ports:
- "27017:27017"
volumes:
- ./data/db:/data/db
hostname: mongo
spring:
depends_on:
- mongo
image:docker-spring-http-alpine
ports:
- "8080:8080"
hostname: spring
links:
- mongo