clair: Connection refused between docker container of clair and pgsql

When I try to run the docker container of clair, there is something wrong with the connection to my pgsql. The docker logs are quoted as follows.

2016-04-05 10:27:47.078096 I | pgsql: running database migrations
2016-04-05 10:27:47.079614 E | pgsql: dial tcp [::1]:5432: getsockopt: connection refused
2016-04-05 10:27:47.079655 C | main: database: could not open database

I have tried several ways and on different machines and the issue still exists.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Faced the same problem. Figured out that connection URL to the database should not be localhost or 127.0.0.1. It should be URL to your container with the Postgres. So the easiest way to do it is to define something like container_name: clair_postgres in the docker-compose.yml and use it as a connection string postgresql://postgres:password@clair_postgres:5432?sslmode=disable

Did you fill the pgsql setting in your config.yaml file and started with it?

  database:
    # PostgreSQL Connection string
    # http://www.postgresql.org/docs/9.4/static/libpq-connect.html
    source: