docker / scout-cli

Docker Scout CLI
https://docker.com/products/docker-scout
Other
252 stars 60 forks source link

temporary file/cache location configurability #75

Closed gergelyfabian closed 7 months ago

gergelyfabian commented 7 months ago

I'm trying to use docker scout from a Bazel test target, that gives restricted access to a user's home directory. Thus, docker scout fails with a similar error:

ERROR   Status: failed to write sbom: open /home/user/.docker/scout/sbom/sha256/ff26ee2d81e043488707fbfb3796ff79086cd24fb6c00fb880780c3b7386c30c/sbom.json: read-only file system, Code: 1 

Is there a way to reconfigure docker scout to write temporary files or cached files into a different location? If this is not currently supported, could you provide some link to source code where this could be added (maybe I could contribute it).

cdupuis commented 7 months ago

You can try setting DOCKER_SCOUT_CACHE_DIR env var to have docker scout use a different cache location. Alternatively, you can also disable caching completely with DOCKER_SCOUT_NO_CACHE.

Let me know if that works.

gergelyfabian commented 7 months ago

Tried both:

DOCKER_SCOUT_CACHE_DIR=$TEST_TMPDIR/scout_cache docker scout cves ...
DOCKER_SCOUT_NO_CACHE=true docker scout cves ...

The error I get is (the same whether I provide these env vars or not):

ERROR   Status: failed create to sbom folder: mkdir /home/user/.docker/scout/sbom/sha256/a94bfdf20e311ab7b601639db53512dec6f3debbe10d0fdca8de3527d1e64766: read-only file system, Code: 1 
version: v1.2.0 (go1.21.3 - linux/amd64)
git commit: 4f69249fb62a3d644dbaf7d9ddb3046e3b8bd35c
cdupuis commented 7 months ago

Thanks for reporting back. Let me take a look at this more.

cdupuis commented 7 months ago

Opps, I see what's wrong here. Let me push a fix.

gergelyfabian commented 7 months ago

Opps, I see what's wrong here. Let me push a fix.

Thank you so much!

gergelyfabian commented 7 months ago

How could I test the fix?

cdupuis commented 7 months ago

Fix pushed. Waiting for release now.

cdupuis commented 7 months ago

Version 1.2.1 is now released.

gergelyfabian commented 7 months ago

After upgrading to 1.2.1 it works with:

export DOCKER_SCOUT_CACHE_DIR=$TEST_TMPDIR/scout_cache

It doesn't work though with:

export DOCKER_SCOUT_NO_CACHE=true

Could these env vars be added to documentation? I see it mentioned in the docker scout cache df documentation, but it's not mentioned for other commands or the general docs. Also, I guess it would be useful to add a mention for them in the error message if the SBOM file could not be written due to file system permission errors.

cdupuis commented 7 months ago

@gergelyfabian I've added docs about the available env vars to https://github.com/docker/scout-cli/blob/main/README.md#environment-variables. This will also be added to the official docs at docs.docker.com soon.

export DOCKER_SCOUT_NO_CACHE=true

Yes, saw that too and already pushed a fix. Previously this env var was only not reading from the cache but we were still attempting to write. This will be fixed in the next version.

gergelyfabian commented 7 months ago

Thank you for all the fixes!