我有一个docker-compose.yml文件,其中包含以下内容:
version: "3"
services:
mysql:
image: "my-mysql:latest"
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: rootpw
backend:
image: "my-backend:latest"
ports:
- 19001:19001
- 80:80
- "9001:9000"
environment:
DB_USERNAME: test
DB_PASSWORD: test
DB_URL: jdbc:mysql://mysql:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&verifyServerCertificate=false&useSSL=true
jdbc_url: jdbc:mysql://mysql:3306
# command: dockerize -wait tcp://my-mysql:3306 -timeout 120s bin/playBinary
links:
- "mysql:mysql"
运行docker-compose up
时 - 收到此错误:
mysql_1 | 2018-03-28T16:43:45.595308Z 0 [Note] Event Scheduler: Loaded 0 events
mysql_1 | 2018-03-28T16:43:45.597913Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
mysql_1 | 2018-03-28T16:43:45.598094Z 0 [Note] Beginning of list of non-natively partitioned tables
mysql_1 | 2018-03-28T16:43:45.611072Z 0 [Note] End of list of non-natively partitioned tables
mysql_1 | 2018-03-28T16:43:45.611935Z 0 [Note] mysqld: ready for connections.
mysql_1 | Version: '5.7.17' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL)
backend_1 | [info] - application - Creating Pool for datasource 'wherehows'
backend_1 | Oops, cannot start the server.
backend_1 | com.google.inject.CreationException: Guice creation errors:
backend_1 |
backend_1 | 1) Error in custom provider, Configuration error: Configuration error[Cannot connect to database [test]]
如何在尝试启动第二个(后端)容器之前使第一个容器(MySQL)完全(100%)加载?
答案 0 :(得分:0)
选项取决于
version: '3'
services:
web:
build: .
depends_on:
- db
- redis
redis:
image: redis
db:
image: postgres