Docker-compose check if mysql connection is ready

后端 未结 9 2144
一个人的身影
一个人的身影 2020-11-27 13:40

I am trying to make sure that my app container does not run migrations / start until the db container is started and READY TO accept connections.

So I decided to use

9条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 14:18

    RESTART ON-FAILURE

    Since v3 condition: service_healthy is no longer available. The idea is that the developer should implement mechanism for crash recovery within the app itself. However for simple use cases a simple way to resolve this issue is to use restart option.

    If mysql service status causes your application to exited with code 1 you can use one of restart policy options available. eg, on-failure

    version: "3"
    
    services:
    
        app:
          ...
          depends_on:
            - db:
          restart: on-failure
    

提交回复
热议问题