问题
I followed example from : https://zaproxy.blogspot.com/2017/06/scanning-apis-with-zap.html
- install Docker on my Mac
- executed
docker pull owasp/zap2docker-weekly
- executed example:
docker run -t owasp/zap2docker-weekly zap-api-scan.py -t \ https://www.example.com/openapi.json -f openapi
it works - executed my command to scan my API :
docker run -v /etc/hosts:/etc/hosts -v $(pwd):/zap/wrk:rw -t owasp/zap2docker-weekly zap-api-scan.py -t myapitest.json -f openapi
And I got: Unable to find image 'in:latest' locally docker: Error response from daemon: pull access denied for in, repository does not exist or may require 'docker login'. I googled to find the solution, as I'm novice both in Docker and ZAP, but in vain.
回答1:
Your current working directory likely has spaces in its path. Because of this, -v $(pwd):/zap/wrk:rw
is seen as two arguments, and the second one is seen as name of the image to run.
For example:
# create a directory having spaces, last part is "baz"
mkdir foo\ bar\ baz
# change to that directory
cd foo\ bar\ baz
# attempt to run a container that bind-mounts the current
# directory, and see that it's producing an error:
docker run --rm -v $(pwd):/foo busybox
Unable to find image 'bar:latest' locally
docker: Error response from daemon: pull access denied for bar, repository does not exist or may require 'docker login'.
What's happening, is that $(foo)
is expanded to its full path:
pwd
/Users/sebastiaan/Projects/spaces/foo bar baz
So, running the docker command actually runs:
docker run --rm -v /Users/sebastiaan/Projects/spaces/foo bar baz:/foo busybox
And docker sees bar
as the name of the image you're trying to run
To work around this, put quotes around $(pwd)
;
docker run --rm -v "$(pwd)":/foo busybox
来源:https://stackoverflow.com/questions/49493851/zaproxy-unable-to-find-image-inlatest-locally