This is a tutorial about how to startup Clair locally using a newer version of Clair.
I am using Mac OS Mojave with Clair version 2.0.9.
There are multiple command line tools which you can use to start Clair.
I used clair-scanner.
To start Clair using clair-scanner
you have to:
- Clone, build clair-scanner and move the binary to $GOPATH/bin folder.
- Run the latest version of the arminc/clair-db nightly image run it with the command
docker run -p 5432:5432 -d --name db arminc/clair-db
The arminc/clair-db
is built nightly by this Tarvis CI job using the .travis.yml inside of clair-local-scan.
- Then you have two options:
a) use the command provided in the README of clair-scanner to run the arminc/clair-local-scan
prebuild image.
The problem with that method is that this image uses an older version of Clair.
b) build your own version of the arminc/clair-local-scan
container with a newer version of Clair.
The arminc/clair-local-scan
image is built with this Dockerfile inside of clair-local-scan.
- If you want to build the arminc/clair-local-scan image for a newer version of Clair just copy the config and Dockerfile from here. If you want to build your image with a specific version of Clair change the VERSION attribute value otherwise you will use the latest version available. Use the command:
docker build -t <NAME_OF_YOUR_CLAIR_IMAGE> .
- Then run
docker run -p 6060:6060 --link db:postgres -d --name clair <NAME_OF_YOUR_CLAIR_IMAGE>
-
To run
clair-scanner
you have to find your local ip: https://www.wikihow.com/Find-Your-IP-Address-on-a-Mac -
Before running
clair-scanner
make sure that you have pulled the image with
docker pull <IMAGE_FOR_SCAN>
command.
- Finally, you can start
clair-scanner
with the command
clair-scanner --ip <YOUR_LOCAL_IP> <IMAGE_FOR_SCAN>
PS: If you have errors like Error response from daemon: Conflict. The container name "/clair" is already in use by container <CONTAINER_HASH>
then you will have to remove the container with the
docker rm <CONTAINER_HASH>
command.
If you still have problems there is a Troubleshooting section of the README.