postgresql - 带有 PostgreSQL 的 CI/CD 管道因“数据库未初始化且未指定超级用户密码”错误而失败
问题描述
我将 Bitbucket 管道与 PosgreSQL 一起用于 CI/CD。根据这个文档PostgreSQL 服务是这样描述的bitbucket-pipelines.yml
:
definitions:
services:
postgres:
image: postgres:9.6-alpine
直到现在它工作得很好。但是我所有最新的管道都失败了,并出现以下错误:
Error: Database is uninitialized and superuser password is not specified.
You must specify POSTGRES_PASSWORD for the superuser. Use
"-e POSTGRES_PASSWORD=password" to set it in "docker run".
You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections
without a password. This is *not* recommended. See PostgreSQL
documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
我该如何解决?文件没有变化,bitbucket-pipelines.yml
这可能是导致此类错误的原因..
解决方案
看起来原因是 docker 图像的更新(github问题)。最新版本不允许在没有密码的情况下从任何地方连接到数据库。所以你需要指定用户名/密码:
definitions:
services:
postgres:
image: postgres:9.6-alpine
environment:
POSTGRES_DB: pipelines
POSTGRES_USER: test_user
POSTGRES_PASSWORD: test_user_password
或者如果您仍然不想使用密码,您可以设置POSTGRES_HOST_AUTH_METHOD=trust
环境变量:
definitions:
services:
postgres:
image: postgres:9.6-alpine
environment:
POSTGRES_HOST_AUTH_METHOD: trust
推荐阅读
- c++ - 在 C++ 中的 Z3 中获取位向量中的数值
- python - 反斜杠运算符在 Python 中的作用是什么?
- android - 循环显示动画在第一次通话中不起作用
- javascript - 'createConsumer' 不是由 node_modules/@rails/actioncable/app/assets/javascripts/action_cable.js 导出的
- c++ - C++ 输出对齐
- python - 如何获取非空值的百分比?
- c# - MongoDB .net 驱动程序 - 获取 MongoDB 服务器版本
- networking - 不用ip访问树莓派
- paypal - PayPal API 返回 RESOURCE_NOT_FOUND / INVALID_RESOURCE_ID 但交易列在 Sandbox Business 帐户中
- java - JsperReport 在 JavaFx 中不显示任何数据