【发布时间】:2020-04-08 00:36:32
【问题描述】:
我有一个 docker-compose.yml 配置为创建数据并将其添加到数据库。然后我的 compose 文件加载到一个 bash 脚本中,该脚本将对数据运行一些简短的测试,并在测试失败时退出 1。这按预期工作,但是当我希望我的容器在所有测试通过但 docker-entrypoint.sh 脚本似乎忽略我的 exit 0 命令时退出。我试图编写一个不同的入口点脚本,它将调用 docker-entrypoint.sh,希望我可以退出容器,但我没有任何运气。有没有简单的方法来实现这个?
输出示例:
postgres_1 | PostgreSQL init process complete; ready for start up.
postgres_1 |
postgres_1 | 2020-04-06 19:29:58.511 UTC [1] LOG: starting PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
postgres_1 | 2020-04-06 19:29:58.511 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2020-04-06 19:29:58.511 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2020-04-06 19:29:58.517 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2020-04-06 19:29:58.534 UTC [102] LOG: database system was shut down at 2020-04-06 19:29:58 UTC
postgres_1 | 2020-04-06 19:29:58.540 UTC [1] LOG: database system is ready to accept connections
【问题讨论】:
-
容器中还有其他东西在运行吗?容器在其中的所有进程都死掉之前不会退出。
-
查看我的编辑 - 它只是说数据库系统已准备好接受连接。我希望它在我所有的测试都通过后结束。
标签: bash postgresql docker