anchore / anchore-engine

A service that analyzes docker images and scans for vulnerabilities
Apache License 2.0
1.57k stars 273 forks source link

anchore-engine add image failed #199

Open mohamedoul opened 5 years ago

mohamedoul commented 5 years ago

Hi, I have installed anchore engine locally (127.0.0.1), when I use anchore-cli to scan images it works but when I try to use it with ci/cd pipeline with Jenkins, Dockerfile and Jenkinsfile I got an error. I have performed this actions: -Installed the anchor plugin and configure it. -Dockerfile and jenkinsfile are in a github repository. The error that I got is as follows:

2019-05-20T10:50:20.930 ERROR AnchoreWorker anchore-engine add image failed. URL: http://127.0.0.1:8228/v1/images, status: HTTP/1.1 400 BAD REQUEST, error: { "detail": { "error_codes": [ "REGISTRY_PERMISSION_DENIED" ], "raw_exception_message": "Error encountered in skopeo operation. cmd=/bin/sh -c skopeo inspect --raw --tls-verify=false docker://docker.io/library/hellonode:latest, rc=1, stdout=None, stderr=b'time=\"2019-05-20T08:50:20Z\" level=fatal msg=\"Error reading manifest latest in docker.io/library/hellonode: errors:\ndenied: requested access to the resource is denied\nunauthorized: authentication required\n\" \n', error_code=REGISTRY_PERMISSION_DENIED" }, "httpcode": 400, "message": "cannot fetch image digest/manifest from registry" }

2019-05-20T10:50:20.931 ERROR AnchorePlugin Failing Anchore Container Image Scanner Plugin step due to errors in plugin execution hudson.AbortException: Failed to analyze hellonode due to error adding image to anchore-engine. Check above logs for errors from anchore-engine at com.anchore.jenkins.plugins.anchore.BuildWorker.runAnalyzerEngine(BuildWorker.java:257) at com.anchore.jenkins.plugins.anchore.BuildWorker.runAnalyzer(BuildWorker.java:177) at com.anchore.jenkins.plugins.anchore.AnchoreBuilder.perform(AnchoreBuilder.java:335) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80) at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67) at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 2019-05-20T10:50:20.931 INFO AnchorePlugin Completed Anchore Container Image Scanner step [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: Failed to analyze hellonode due to error adding image to anchore-engine. Check above logs for errors from anchore-engine Finished: FAILURE

nurmi commented 5 years ago

hi @mohamedoul

From that output:

"raw_exception_message": "Error encountered in skopeo operation. cmd=/bin/sh -c skopeo inspect --raw --tls-verify=false docker://docker.io/library/hellonode:latest, rc=1, stdout=None, stderr=b'time="2019-05-20T08:50:20Z" level=fatal msg="Error reading manifest latest in docker.io/library/hellonode: errors:\ndenied: requested access to the resource is denied\nunauthorized: authentication required\n" \n', error_code=REGISTRY_PERMISSION_DENIED"

it looks as if either the image (docker.io/library/hellonode:latest) doesn't exist in dockerhub, or that it does exist but you need registry credentials to access it (you get back the same response from docker registry in either case). Can you verify that this is a correct image that you're attempting to add to anchore?

you can validate using docker itself, for testing:

# docker pull docker.io/library/hellonode:latest
Trying to pull repository docker.io/library/hellonode ... 
repository docker.io/hellonode not found: does not exist or no pull access
VaibhavKhalane commented 4 years ago

I have docker repo which requires authentication. I am facing same issue. Where should I provide the credentials?

jujugrrr commented 4 years ago

In case it's useful to someone, you just need to add the registry to anchore. Be careful, the registry name has to match.

anchore-cli registry add myregistry.docker.local DOCKER_USERNAME DOCKER_PASSWORD