clair-scanner icon indicating copy to clipboard operation
clair-scanner copied to clipboard

change port for arminc/clair-db as a docker postgresql container is running on the same port

Open abhishiktvv opened this issue 7 years ago • 6 comments

Hi, could you please let me know while running the command docker run -p 5432:5432 -d --name db arminc/clair-db:2017-09-18 , i already have a postgres container for my project running on that 5432 port, if i simple change docker run -p 5432:5432 -d --name db arminc/clair-db:2017-09-18 this port number to docker run -p XXXX:XXXX -d --name db arminc/clair-db:2017-09-18 would the scanner work fine or does it gives any error?

abhishiktvv avatar Jul 31 '18 03:07 abhishiktvv

You can't change the port that easily because it is configured in clair here https://github.com/arminc/clair-local-scan/blob/master/clair/config.yaml. You can do two things:

  1. Create your own Docker container with Clair - here is the one I provide -> https://github.com/arminc/clair-local-scan/tree/master/clair and change the port there
  2. Instead of exposing the DB port link the DB container with the Clair container trough Docker

arminc avatar Jul 31 '18 06:07 arminc

Thanks , i will check it and let you know :)

abhishiktvv avatar Jul 31 '18 09:07 abhishiktvv

Hi, can you just throw some light on how to build the container after modifiying the DB port in config.yaml in https://github.com/arminc/clair-local-scan/tree/master/clair

On Tue, Jul 31, 2018 at 12:02 PM Armin Coralic [email protected] wrote:

You can't change the port that easily because it is configured in clair here https://github.com/arminc/clair-local-scan/blob/master/clair/config.yaml. You can do two things:

  1. Create your own Docker container with Clair - here is the one I provide -> https://github.com/arminc/clair-local-scan/tree/master/clair and change the port there
  2. Instead of exposing the DB port link the DB container with the Clair container trough Docker

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arminc/clair-scanner/issues/51#issuecomment-409110493, or mute the thread https://github.com/notifications/unsubscribe-auth/AL2vFh8d9pnHu2Ewzkll8g5z9Ksw2fu4ks5uL_nngaJpZM4Vnjh9 .

abhishiktvv avatar Aug 07 '18 10:08 abhishiktvv

i have created a container using docker build, then when i try to run modified build it says dial tcp error 172.17.0.2:XXXX XXXX(is the modified port). can you just say me where was i going wrong

abhishiktvv avatar Aug 07 '18 10:08 abhishiktvv

This is not an issue for me but posting because I'm curious what's going on.

I'm running your image by following GitLab's docs https://docs.gitlab.com/ce/ci/examples/container_scanning.html

If I use arminc/clair-db:latest the container starts up:

2019-02-22 16:31:33.014 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2019-02-22 16:31:33.015 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2019-02-22 16:31:33.021 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-02-22 16:31:33.070 UTC [18] LOG:  database system was shut down at 2019-02-21 01:43:33 UTC
2019-02-22 16:31:33.080 UTC [1] LOG:  database system is ready to accept connections

But if I clone https://github.com/arminc/clair-local-scan, docker build --tag clair-test ., and docker run clair-test I get the issue described above:

{"Event":"pgsql: could not open database: dial tcp: lookup postgres on 192.168.65.1:53: no such host","Level":"fatal","Location":"main.go:96","Time":"2019-02-22 16:30:54.080244"}

There seems to be a difference between how arminc/clair-db:latest was built and the images built using this Dockerfile https://github.com/arminc/clair-local-scan/blob/master/clair/Dockerfile.

yegorski avatar Feb 22 '19 16:02 yegorski