If the Docker daemon's socket path is not /var/run/docker.sock, you need to specify the --docker-host flag or the DOCKER_HOST environment variable.
The same applies when using TCP; you must specify the correct host address.
Running in parallel takes same time as series run¶
When running trivy on multiple images simultaneously, it will take same time as running trivy in series.
This is because of a limitation of boltdb.
Bolt obtains a file lock on the data file so multiple processes cannot open the same database at the same time. Opening an already open Bolt database will cause it to hang until the other process closes it.
To run multiple Trivy servers, you need to use Redis as the cache backend so that those servers can share the cache.
Follow this instruction to do so.
Problems with /tmp on remote Git repository scans¶
Error
FATAL repository scan error: scan error: unable to initialize a scanner: unable to initialize a filesystem scanner: git clone error: write /tmp/fanal-remote...
Trivy clones remote Git repositories under the /tmp directory before scanning them. If /tmp doesn't work for you, you can change it by setting the TMPDIR environment variable.
If the image is large or the temporary directory has insufficient space, the scan will fail.
You can configure the directory path to redirect Trivy to a directory with adequate storage.
On Unix systems, you can set the $TMPDIR environment variable.
$ TMPDIR=/my/custom/path trivy image ...
When scanning images from a container registry, Trivy processes each layer by streaming, loading only the necessary files for the scan into memory and discarding unnecessary files.
If a layer contains large files that are necessary for the scan (such as JAR files or binary files), Trivy saves them to a temporary directory (e.g. $TMPDIR) on local storage to avoid increased memory consumption.
Although these files are deleted after the scan is complete, they can temporarily increase disk consumption and potentially exhaust storage.
In such cases, there are currently three workarounds:
Use a temporary directory with sufficient capacity
This is the same as explained above.
Specify a small value for --parallel
By default, multiple layers are processed in parallel.
If each layer contains large files, disk space may be consumed rapidly.
By specifying a small value such as --parallel 1, parallelism is reduced, which can mitigate the issue.
Specify --skip-files or --skip-dirs
If the container image contains large files that do not need to be scanned, you can skip their processing by specifying --skip-files or --skip-dirs.
For more details, please refer to this documentation.
Error: Your macOS keychain GitHub credentials do not have sufficient scope!
$ brew tap aquasecurity/trivy
Error: Your macOS keychain GitHub credentials do not have sufficient scope!
Scopes they need: none
Scopes they have:
Create a personal access token:
https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.zshrc