mysql容器只链接到一个容器

时间:2017-05-25 11:40:07

标签: docker docker-compose dockerfile

这是docker-compose.yml文件

 mySql:
      image: mysql:latest
      environment:
         MYSQL_PASSWORD: root
  myContainer1:
      image: container1:latest
      ports:
         - 9000:9000
      links:
         - mySql:dev-mysql
  myContainer2:
      image: container2:latest
      ports:
          - 9001:9000
      links:
          - mySql:dev-mysql
          - myContainer1:dev

现在,当我运行此文件时,我使用myContainer1获取MySql超时错误,但使用myContainer2它正常工作。

myContainer1的错误日志:

  

线程“main”中的异常java.sql.SQLTimeoutException:之后的超时   10001ms等待连接。       在com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:227)       在com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:182)       在com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:93)       在slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:12)       at slick.jdbc.JdbcBackend $ BaseSession.conn $ lzycompute(JdbcBackend.scala:415)       at slick.jdbc.JdbcBackend $ BaseSession.conn(JdbcBackend.scala:414)       at slick.jdbc.JdbcBackend $ SessionDef $ class.prepareStatement(JdbcBackend.scala:297)       at slick.jdbc.JdbcBackend $ BaseSession.prepareStatement(JdbcBackend.scala:407)       at slick.jdbc.StatementInvoker.results(StatementInvoker.scala:33)       在slick.jdbc.StatementInvoker.iteratorTo(StatementInvoker.scala:22)       在slick.jdbc.Invoker $ class.foreach(Invoker.scala:48)       在slick.jdbc.StatementInvoker.foreach(StatementInvoker.scala:16)       在slick.jdbc.StreamingInvokerAction $ class.run(StreamingInvokerAction.scala:22)       at slick.driver.JdbcActionComponent $ QueryActionExtensionMethodsImpl $$ anon $ 1.run(JdbcActionComponent.scala:218)       at slick.driver.JdbcActionComponent $ QueryActionExtensionMethodsImpl $$ anon $ 1.run(JdbcActionComponent.scala:218)       at slick.backend.DatabaseComponent $ DatabaseDef $$ anon $ 2.liftedTree1 $ 1(DatabaseComponent.scala:237)       at slick.backend.DatabaseComponent $ DatabaseDef $$ anon $ 2.run(DatabaseComponent.scala:237)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在java.lang.Thread.run(Thread.java:748)

0 个答案:

没有答案