Unfortunately that didn’t work for me. I did a “docker login” and that worked, but gave me the same error above.
If I tried adding --login the command fails:
–login flag expects no argument
no matter where I put the flag. I then checked Docker Hub and note it says:
vulnerability scanning - disabled
If I try to enable it, I’m told I must upgrade to a Pro license. So maybe they just changed this? Or perhaps you’re all paying customers? Otherwise not sure what I’m doing wrong. Rest of the tutorial went fine.
Thanks for your help. I just started with Docker yesterday and this was my first attempt at a scan, and I’m confident I haven’t even made 10 failures (yet!). Looking at the cheat sheet, it says I should get 10 “Local vulnerability scans” with the free edition, and 200 with Snyk. The ones I don’t get are the Hub scans. But still, it doesn’t work for me and maybe it’s a syntax issue I’m blind to:
PS D:\Downloads\app> docker scan getting-started
failed to get DockerScanID: bad status code "400 Bad Request"
PS D:\Downloads\app> docker scan getting-started --accept-license
failed to get DockerScanID: bad status code "400 Bad Request"
PS D:\Downloads\app> docker scan getting-started --login
--login flag expects no argument
I’ve solved the problem, here are all the details. Note it seems you may be using an older version, because your comments don’t align with the command output or docs. Do appreciate the help, though!
First, I had successfully logged in with:
docker login -u username
But that logs me into Docker Hub. What the docs fail to mention is that I also need to register with Snyk first.
The Vulnerability scanning feature doesn’t work with Alpine distributions.
If you are using Debian and OpenSUSE distributions, the login process only works with the --token flag, you won’t be redirected to the Snyk website for authentication.
Both warnings are for WSL, which I am using (probably obvious from the D:\ in my paths). That’s where I discovered I needed a token for login, but when I created a Docker Hub auth token and used that, I got a clue in the form of an error message:
PS D:\Downloads\app> docker scan --login --token TOKEN
Authentication failed. Please check the API token on https://snyk.io
Aha! I then registered on Snyk, got the token, and retried the above command with the Snyk token. Success:
Your account has been authenticated. Snyk is now ready to be used.
After logging in, I’m able to successfully scan with (truncated output):
I read “exactly 1 argument” as the IMAGE argument in the usage line. Not that an option might count as an argument. Or that with --login option, takes zero arguments. If I may be so bold, that conflict makes the command help/error message incorrect. Or at a minimum, imprecise.
I am trying to run this command but it’s not woking. it’s always asking to login to Dockerhub. Login to dockerhub is must to run the scan?
docker scan --token dsd-sd2-2222-4dsd-sds nginx:latest
Token is from Snyk.
If I use the command like this
docker scan --login --token dsd-sd2-2222-4dsd-sds nginx:latest
then it throw this error,
–login flag expects no argument
Looks like login to dockerhub is must to use Docker Scan. It may be cost thing