Docker wait for postgresql to be running

2019-02-03 15:31发布

I am using postgresql with django in my project. i've got them in different containers and the problem is that i need to wait for postgres before running django. At this time i am doing it with sleep 5 in command.sh file for django container. I also found that netcat can do the trick but i would prefer way without additional packages. curl and wget can't do this because they do not support postgres protocol. Is there a way to do it?

7条回答
smile是对你的礼貌
2楼-- · 2019-02-03 16:04

Why not curl?

Something like this:

while ! curl http://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/ 2>&1 | grep '52'
do
  sleep 1
done

It works for me.

查看更多
登录 后发表回答