在启动时pipe理容器依赖关系

我有以下设置:

  • PostgreSQL的
  • 为它飞行
  • 应用

我需要按照以下方式链接它们:Flyway等待DB启动,App等待飞行路线完成迁移。

我想过使用etcd来发布一些密钥,其他容器等待它们。 所以,基本上,每个容器的入口点应该是这样的:

 #!/bin/bash status=1 while $status != 0; do for kv in $DEPENDENT_KEYS: # curl to etcd, get the key if $value == true then status = 0; else status = 1; fi; done; # container-related startup # post to etcd that container is ready # get back to _container-related startup_ 

我的问题是:

1)我做对了吗?

2)我怎么能脱离进程,然后重新附加到它没有安装太多额外的实用程序(假设我使用busybox / debian作为基础映像)

PS我想到了supervisord,它很接近,但我不知道如何让进程在那里等待(并链接它们)PPS所有的设置都是由Docker Compose来执行的。