docker-compose控制启动顺序问题


docker-compose配置两个应用,mysql和rabbitmq
在rabbitmq里配置了links,但是不起作用,在hosts里没建立配置,是不是顺序问题?
version: "2"
services:
db:
container_name: "mysql"
image: mysql:5.7.12
hostname: mysql
restart: always
expose:
  - 3306
ports:
  - 3306:3306
volumes:
  - "/opt/spring-demo/mysql/var/lib/mysql:/var/lib/mysql"
environment:
  - MYSQL_ROOT_PASSWORD=123456789
  - MYSQL_DATABASE=test
  - character-set-server=utf8mb4
  - collation-server=utf8mb4_unicode_ci

rabbitmq:
container_name: rabbitmq
image: rabbitmq:custom
hostname: rabbitmq
restart: always
depends_on:
  - db
expose:
  - 5672
  - 15672
ports:
  - 5672:5672
  - 15672:15672
environment:
  - RABBITMQ_DEFAULT_USER=test
  - RABBITMQ_DEFAULT_PASS=test
  - RABBITMQ_DEFAULT_VHOST=test
links:
  - db
已邀请:

要回复问题请先登录注册