docker-compose java application connection to mongodb

前端 未结 2 532
醉梦人生
醉梦人生 2021-01-28 02:35

2 Containers, one Java application and the second mongodb.

If I run my java app locally and mongodb in a container, it connects but if both run inside a container, java

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-28 03:25

    You probably cant connect because you set the MONGO_HOST as localhost and mongo is a linked service.

    In order to use linked services network, you must specify the MONGO_HOST as the name of the service - mongo, like that:

     MONGO_HOST=mongo
    

提交回复
热议问题