Docker-compose check if mysql connection is ready

后端 未结 9 2117
一个人的身影
一个人的身影 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:05

    This should be enough

    version: '2.1'
    services:
      mysql:
        image: mysql
        ports: ['3306:3306']
        environment:
          MYSQL_USER: myuser
          MYSQL_PASSWORD: mypassword
        healthcheck:
          test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
    

提交回复
热议问题