当你的主容器完成它的工作时如何终止同一个 pod 中的另一个容器
How to terminate another container in the same pod when your main container finish its job
使用 OpenShift 3.9,我 运行 一个由 2 个容器组成的日常 CronJob:
- Redis 服务器
- 使用 Redis 服务器的 Python 脚本
当python脚本完成执行时,容器正常终止,但Redis服务器容器保持运行。
有没有办法让Redis服务器容器在python脚本退出时自动终止执行? docker compose 的 depends_on 有等价物吗?
根据 Dawid Kruk 的评论,我在 python 脚本的末尾添加了这一行以关闭服务器:
os.system('redis-cli shutdown NOSAVE')
它有效地终止了容器。
使用 OpenShift 3.9,我 运行 一个由 2 个容器组成的日常 CronJob:
- Redis 服务器
- 使用 Redis 服务器的 Python 脚本
当python脚本完成执行时,容器正常终止,但Redis服务器容器保持运行。
有没有办法让Redis服务器容器在python脚本退出时自动终止执行? docker compose 的 depends_on 有等价物吗?
根据 Dawid Kruk 的评论,我在 python 脚本的末尾添加了这一行以关闭服务器:
os.system('redis-cli shutdown NOSAVE')
它有效地终止了容器。