运行docker镜像时出错

时间:2017-07-19 09:39:32

标签: mongodb maven docker spring-boot

我在执行我创建的图像时遇到了一些问题。该服务需要连接到mongodb,即使它已启动并且它侦听localhost:27017

以下是错误:

INFO 5 --- [localhost:27017] org.mongodb.driver.cluster               :  Exception in monitor thread while connecting to server localhost:27017

[main] org.mongodb.driver.cluster               : No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=MULTIPLE, all=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]}. Waiting for 30000 ms before timing out

1 个答案:

答案 0 :(得分:0)

弹簧:

个人资料:prod,默认

数据:

mongodb:

  database: robotTxt

  host: localhost

  repositories:

    enabled: true

日志记录:

图案:   file:“%d {yyyy-MM-dd HH:mm:ss} [%thread]%-5level%logger {36} - %msg%n”

console:“%d {yyyy-MM-dd HH:mm:ss} - %msg%n”

级别:

ROOT:ERROR

org.springframework:ERROR

org.springframework.data:ERROR

org.mongodb:ERROR

file:$ {java.io.tmpdir} /application.log