执行ZAP API扫描命令时提示无法找到'in:latest'镜像的问题求助
That error pops up because Docker's parameter parser gets confused by unquoted whitespace in your current directory path — it splits the -v mount argument into multiple parts, and ends up misinterpreting one of those fragments as an image name (in:latest). Here's how to fix it step by step:
Step 1: Quote the Current Directory Path
Wrap $(pwd) in double quotes to stop whitespace from breaking the mount argument. This is the most common fix for this issue on Mac:
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
Without quotes, if your working directory has spaces (like ~/My API Projects/Tests), $(pwd) expands to multiple separate words. Docker then treats the word after the space as a new image name instead of part of the mount flag.
Step 2: Verify Your Local JSON File Exists
Make sure myapitest.json is actually in the directory where you're running the command. Since you're mounting your current directory to /zap/wrk in the container, ZAP will look for the file at /zap/wrk/myapitest.json — if it's missing, you'll hit another error after fixing the image issue.
Step 3: Simplify to Rule Out Other Variables
If you're still stuck, strip down the command first to eliminate extra variables:
# Test without the /etc/hosts mount first docker run -v "$(pwd)":/zap/wrk:rw -t owasp/zap2docker-weekly zap-api-scan.py -t myapitest.json -f openapi
If this works, add back the /etc/hosts mount — it's unlikely to cause the image error, but narrowing down variables helps pinpoint issues faster.
Optional: Refresh the ZAP Docker Image
If you haven't pulled the latest weekly image in a while, refresh it to avoid any outdated image quirks:
docker pull owasp/zap2docker-weekly
内容的提问来源于stack exchange,提问作者Alex

