postgresql - docker 容器不会在 Amazon Codebuild 上启动 postgres 服务器
问题描述
我正在使用自定义 docker 容器来构建代码,该容器与 Amazon codebuild 集成。AWS codebuild 启动一个 Docker 容器并在我们提供的容器上构建代码。我写的容器的 Dockerfile 是这样的 -> Dockerfile
Docker 容器应该安装了 Java-8、Gradle-4.7 和 Postgres-10。
我在本地机器上运行 Docker 容器,可以看到 Postgres 服务正在运行。但是,在 AWS codebuild 上,docker 容器不会启动 Postgres 服务器。我尝试使用 buildspec.yml 文件中的命令了解 Postgres 的状态,结果发现它已关闭。
以下是我可以在 cloudwatch 日志中看到的错误 -
May 18, 2018 9:26:33 AM org.postgresql.Driver connect
SEVERE: Connection error:
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
有人对此有任何想法吗?Dockerfile 是否正确?
解决方案
问题实际上可能是入口点(在您提到的 Dockerfile 中)。
CodeBuild 将覆盖每次运行时的入口点,这与您在本地 docker run 中看到的不同(您也可以使用 codebuild 本地代理测试此行为)
"ENTRYPOINT ["/etc/init.d/postgresql", "start"]"
您可以发布您的 buildspec.yml 文件吗?对此的简单解决方法是将入口点命令作为 buildspec.yml 的一部分运行
推荐阅读
- javascript - 我对函数 mouseeneter 有疑问
- typescript - 如何在 TypeScript 中返回泛型类型
- c# - 在 MongoDB 中搜索文本时 $text 查询错误需要文本索引
- node.js - 如何在 Class 方法的模型中导入其他 Sequelize 模型。续集 v 5
- java - 在战争之间共享公共库是一件好事吗?你应该寻找什么?
- flutter - FIREBASE_MESSAGING:当应用程序处于后台或终止时,onBackgroundMessage 不处理通知
- c# - 如何修复表截断的 SQL 注入问题
- flutter - 如何解决flutter中的一堆卡片布局问题
- python - 用 Python 抓取 Edmunds.com 网站时如何处理读取超时错误?
- c++ - 使用 C++ 使用 Shunting Yard 算法处理括号