Mariadb docker container Can't connect to MySQL server on host (111 Connection refused) with Python

后端 未结 2 2048
死守一世寂寞
死守一世寂寞 2021-01-24 23:51

I am trying the connect mariadb with python using docker-compose:

docker-compose.yml

    version: \'2\'
    services:
      mariadb:
        image: bitna         


        
2条回答
  •  一个人的身影
    2021-01-25 00:44

    The problem is not with Database or Python code; Its a raise problem coming from Docker, as database needs some time to load and python (consumer.py) container launches faster than database one.

    Possible solutions:

    docker healthcheck

    waittime in docker

    add a delay to the python consumer

提交回复
热议问题