SpringBoot in Docker not connecting to Mongo in Docker

后端 未结 3 564
醉梦人生
醉梦人生 2021-01-13 10:00

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

3条回答
  •  没有蜡笔的小新
    2021-01-13 10:23

    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
    

提交回复
热议问题