一旦依赖容器完成,如何让服务容器退出?
我的测试套件运行在一个postgresql服务器(postgres:9.5-depends_on)中的depends_on容器中,它运行在单独的容器中。一旦测试套件退出,我想检查测试套件的返回代码并停止数据库容器。使用下面的docker-compose.yml,db服务容器永远不会停止。
docker-compose.yml
version: '2.1'
services:
app_postgresql95:
build: ./postgresql95/
ports:
- 54321:5432
app_unittestbot:
command: /root/wait-for-it.sh app_postgresql95:5432 --timeout=60 -- nose2 tests
build: ./unittestbot/
links:
- app_postgresql95
volumes:
- /app/src:/src
depends_on:
- 'app_postgresql95'发布于 2017-06-09 18:12:20
如果任何一个容器退出,您可以运行docker-compose up --abort-on-container-exit让它们停止所有容器。这可能会解决您的用例。
为了获得更好的恢复能力,我可能会将其分成两个组合文件,这样postgresql上的中止就不会意外地注册为成功的测试。然后,您只需按所需顺序运行这些文件:
docker-compose -f docker-compose.yml up -d
docker-compose -f docker-compose.test.yml up
docker-compose -f docker-compose.yml downhttps://stackoverflow.com/questions/44462316
复制相似问题