簡體   English   中英

jenkins 管道中的 docker.withDockerRegistry() 問題

[英]issue with docker.withDockerRegistry() in jenkins pipeline

我正在嘗試通過安裝在 kube.netes 上的 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```
Caused: java.io.IOException: Cannot run program "docker": error=2, No such file or directory

Jenkins 插件要求docker二進制文件存在於運行節點腳本的代理所在的主機上。 您看到的錯誤是二進制文件不存在時報告的錯誤。 您很可能需要安裝 Docker。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM