arminc / clair-scanner

Docker containers vulnerability scan
Apache License 2.0
848 stars 154 forks source link

Does clair-scanner work with Docker Desktop? #114

Open ksed opened 3 years ago

ksed commented 3 years ago

I've installed this via go on an up-to-date Windows 10 machine with Docker Desktop, and have followed the instructions for launching the two db docker containers for the clair-scanner.

Yet, every time I run .\go\bin\clair-scanner.exe --ip="172.17.0.1" --threshold="High" --report="report.json" --log="log.txt" <image name here> , all I get is ... Got response 400 with message {"Error":{"Message":"could not find layer"}}.

Yet when I follow the same steps on a linux box, it works just fine. What gives?

BTW, I found this for getting the IP for the Docker bridge network.

skupfer commented 3 years ago

EDIT:

IPv4 works but the server opened by clair seems to be a ipv6 listener which is not yet supported by Docker Desktop and here.

EDIT:

Could you add IPv4 support for the fileserver?

EDIT: Following change to server.go and make build should fix it (tested on WSL) Line 16, change server := &http.Server{Addr: ":" + httpPort} to server := &http.Server{Addr: "127.0.0.1:" + httpPort}

Warning. Current source throws errors

EDIT: How to build clair-v12

#prepare src directory
mkdir -p /home/$USER/go/src

#install go 1.9.7
sudo rm -rf /usr/local/go
wget https://golang.org/dl/go1.9.7.linux-amd64.tar.gz -O - | sudo tar -xzf - -C /usr/local

#export path or add it .bashrc / .zshrc / ... -> close session / make new session or source the appropriate file
export PATH=$PATH:/usr/local/go/bin

#install dep
sudo apt install go-dep

#download and extract source
wget https://github.com/arminc/clair-scanner/archive/refs/tags/v12.tar.gz -O - | tar -xzf - -C /home/$USER/go/src

#modify file (look above) and compile
cd /home/$USER/go/src
make ensure
make build

#copy new clair-scanner
sudo cp clair-scanner-12 /usr/local/bin/clair-scanner
YevheniiPokhvalii commented 1 year ago

It works with Docker Desktop. Pay attention to the IP address. Here is the issue: https://github.com/arminc/clair-scanner/issues/42

I had to indicate my gateway IP to make it work.