jenkins管道中的docker.withDockerRegistry()出现问题

jogvjijk  于 2022-11-02  发布在  Jenkins
关注(0)|答案(1)|浏览(424)

我试图通过kubernetes上安装的jenkins将docker图像推到ECR存储库,我已经创建了所有内容,即docker图像和ECR存储库。我有一个jenkins管道脚本,它将拉docker图像并将图像推到ECR。我正在使用代码

stage('Push image to ECR'){     
docker.withRegistry("https://807***16.dkr.ecr.us-east-1.amazonaws.com/helloworld", "ecr:us-east-1:ecr") {
                           docker.image('faisalbasha82/helloworld').push('latest')
              }
}

我得到以下错误,我认为这是有关的环境路径不正确,以获得到docker命令。

[Pipeline] { (Push image to ECR)
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withDockerRegistry
$ docker login -u AWS -p********https://807***16.dkr.ecr.us-east-1.amazonaws.com/helloworld
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // podTemplate
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from ip-10-0-28-170.ec2.internal/10.0.28.170:47472
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:955)
        at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1060)
        at hudson.Launcher$ProcStarter.start(Launcher.java:455)
        at hudson.Launcher$ProcStarter.join(Launcher.java:466)
        at org.jenkinsci.plugins.docker.commons.impl.RegistryKeyMaterialFactory.materialize(RegistryKeyMaterialFactory.java:101)
        at org.jenkinsci.plugins.docker.workflow.AbstractEndpointStepExecution2.doStart(AbstractEndpointStepExecution2.java:53)
        at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
        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)
Caused: java.io.IOException: Cannot run program "docker": error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at hudson.Proc$LocalProc.<init>(Proc.java:250)
    at hudson.Proc$LocalProc.<init>(Proc.java:219)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
    at hudson.Launcher$ProcStarter.start(Launcher.java:455)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1319)
    at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1272)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:369)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    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 hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:117)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE```
uidvcgyl

uidvcgyl1#

Caused: java.io.IOException: Cannot run program "docker": error=2, No such file or directory

Jenkins插件要求docker二进制文件存在于正在运行节点脚本的代理所在的主机上。您看到的错误是当该二进制文件不存在时报告的错误。您很可能需要安装Docker。

相关问题