wait-for
Use a tool such as wait-for-it, dockerize, or sh-compatible wait-for. These are small wrapper scripts which you can include in your application’s image to poll a given host and port until it’s accepting TCP connections. For example, to use wait-for-it.sh or wait-for to wrap your service’s command: version: ""
services:
web:
build: .
ports:
- "80:8000"
depends_on:
- "db"
command: ["./wait-for-it.sh", "db:5432", "--", "python", "app.py"]
db:
image: postgres
Tip: There are limitations to this first solution. For example, it doesn’t verify when a specific service is really ready. If you add more arguments to the command, use the bash shift command with a loop, as shown in the next example. Alternatively, write your own wrapper script to perform a more application-specific health check. For example, you might want to wait until Postgres is definitely ready to accept commands: #!/bin/bash
# wait-for-postgres.sh set -e host="$1"
shift
cmd="$@" until psql -h "$host" -U "postgres" -c '\q'; do
>& echo "Postgres is unavailable - sleeping"
sleep
done >& echo "Postgres is up - executing command"
exec $cmd
You can use this as a wrapper script as in the previous example, by setting: command: ["./wait-for-postgres.sh", "db", "python", "app.py"]
随机推荐
- java生成二维码以及读取案例
今天有时间把二维码这块看了一下,方法有几种,我只是简单的看了一下 google 的 zxing! 很简单的一个,比较适合刚刚学习java的小伙伴哦!也比较适合以前没有接触过和感兴趣的的小伙伴,o ...
- 事件(Event)(onclick,onchange,onload,onunload,onfocus,onblur,onselect,onmuse)【转载】
ylbtech-Event:事件(Event)对象 事件(Event) HTML 4.0 事件属性 onclick onchange onload onunload onselect onmouse ...
- IDEA学习——模板及其常用模板
模板及其常用模板 (1)psvm (2)sout sout / soutp / soutv / 变量.sout (3)fori iter增强for循环 itar普通for循环 (4)list.for ...
- Java实现简单记事本
代码实现: import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.ActionEvent; im ...
- Java大数相加-hdu1047
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 题目描述: 题意有点绕,但是仔细的读了后就发现是处理大数相加的问题.注意:输入数据有多组,每组输 ...
- spring框架加载完成后执行上下文刷新事件(ContextRefreshedEvent)
目前spring框架是j2ee比较常用的项目开发技术,只需在web.xml文件中进行少许配置即可,代码如下所示:<!--spring的配置文件--><context-param> ...
- ubantu 执行sudo apt-get update 出现校验不符问题
一直被这个问题困扰,今天安装mongodb时,看了别人博客暂时解决了,不知道会不会出什么问题. 直接打开软件更新器: 然后点击其他软件,去掉两个独立的多选项: 再执行一遍 sudo apt-get u ...
- 1038. Jewels And Stones
描述 给定字符串J代表是珠宝的石头类型,而S代表你拥有的石头.S中的每个字符都是你拥有的一个石头. 你想知道你的石头有多少是珠宝. J中的字母一定不同,J和S中的字符都是字母. 字母区分大小写,因此& ...
- UVA 1592 DataBase
思路: 知识补充: ①make_pair和pair: /*pair是将2个数据组合成一个数据,当需要这样的需求时就可以使用pair,如stl中的map就是将key和value放在一起来保存.另一个应用 ...
- Touch事件详解及区别,触屏滑动距离计算
移动端有四个关于触摸的事件,分别是touchstart.touchmove.touchend.touchcancel(比较少用), 它们的触发顺序是touchstart-->touchmove- ...