gitlab ci 错误 could not translate host name "postgres" to address: Name does not resolve
gitlab ci error could not translate host name "postgres" to address: Name does not resolve
我在我的 rails 应用程序中使用 gitlab-ci,它 运行 正确到昨天
但它没有通过,原因是:
rake aborted!
PG::ConnectionBad: could not translate host name "postgres" to address: Name does not resolve
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `initialize'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `new'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `connect'
....
Tasks: TOP => db:schema:load => db:check_protected_environments
.gitlab-ci.yml :
rspec:
stage: test
services:
- postgres:10
variables:
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
POSTGRES_DB: db_test
RAILS_ENV: test
before_script:
- ruby -v
script:
- cp config/application.sample.yml config/application.yml
- cp config/database.sample.yml config/database.yml
- bundle exec rake db:schema:load
- bundle exec rspec spec
似乎找不到 postgres 服务 运行 或者由于某种原因数据库服务不正确 运行,我猜 gitlab-ci 中的一些内部结构已经改变。
postgres 有两个必需的环境变量名称 POSTGRES_USER
和 POSTGRES_PASSWORD
如果您不提供它们容器将不会 运行。
编辑:这是对图像的有意更改,you now must set a password or configure further:
If you know that you want to be insecure (i.e. any one can connect without a password from anywhere), then POSTGRES_HOST_AUTH_METHOD=trust is how you opt in to that.
这似乎是在 docker 图像升级到 new releases 时引入的。
可以拉取10.11的镜像,暂时避免这个问题:
services:
- postgres:10.11
不确定为什么会这样,但自 last docker image update 以来我们正在经历同样的事情。我发现从 12.1 到 12.2 也是如此。
我在我的 rails 应用程序中使用 gitlab-ci,它 运行 正确到昨天 但它没有通过,原因是:
rake aborted!
PG::ConnectionBad: could not translate host name "postgres" to address: Name does not resolve
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `initialize'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `new'
/usr/local/bundle/gems/pg-1.1.4/lib/pg.rb:56:in `connect'
....
Tasks: TOP => db:schema:load => db:check_protected_environments
.gitlab-ci.yml :
rspec:
stage: test
services:
- postgres:10
variables:
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
POSTGRES_DB: db_test
RAILS_ENV: test
before_script:
- ruby -v
script:
- cp config/application.sample.yml config/application.yml
- cp config/database.sample.yml config/database.yml
- bundle exec rake db:schema:load
- bundle exec rspec spec
似乎找不到 postgres 服务 运行 或者由于某种原因数据库服务不正确 运行,我猜 gitlab-ci 中的一些内部结构已经改变。
postgres 有两个必需的环境变量名称 POSTGRES_USER
和 POSTGRES_PASSWORD
如果您不提供它们容器将不会 运行。
编辑:这是对图像的有意更改,you now must set a password or configure further:
If you know that you want to be insecure (i.e. any one can connect without a password from anywhere), then POSTGRES_HOST_AUTH_METHOD=trust is how you opt in to that.
这似乎是在 docker 图像升级到 new releases 时引入的。
可以拉取10.11的镜像,暂时避免这个问题:
services:
- postgres:10.11
不确定为什么会这样,但自 last docker image update 以来我们正在经历同样的事情。我发现从 12.1 到 12.2 也是如此。