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 not defining the ports of Mongo.
version: '3' services: mongo: container_name: docker-mongo image: mongo:latest volumes: - ./data/db:/data/db spring: depends_on: - mongo image: docker-spring-http-alpine ports: - "8080:8080" links: - mongo