在Amazon Linux 2 AMI上使用Jenkins Docker从站

nwo49xxi  于 2023-01-08  发布在  Jenkins
关注(0)|答案(3)|浏览(274)

我在使用Jenkins提供的标准docker图像时遇到了一个奇怪的问题--只有当Jenkins运行在AmazonLinux 2上时,Jenkins在Ubuntu 18.04上工作正常。
问题是Jenkins无法发射这些奴隶集装箱。
连接方法-“连接Docker容器”,因为Docker引擎在Jenkins服务器上本地运行。
有趣的是,如果我在一个新的DockerFile中设置USER root(Ubuntu上不需要),我已经能够在Amazon Linux上成功地运行这些容器,但是,我需要以非root用户(如jenkins用户)的身份运行这些容器,以便运行postgres的单元测试。
有没有想过我如何在亚马逊Linux 2上实现这一点?我会不会错过了操作系统上的Docker设置或安全设置?

我已测试的Docker映像:

错误不是很有用:

正在连接到Docker容器4486 c8 f2696 f40 c7 de 32160 d 78 d 6 e2438 abb 1ff 92517 c71 cf 66 b 93 baf 3d 0877 f,运行命令java -jar/home/jenkins/remoting-4.6.jar-无重新连接-无保持活动-slaveLog/home/jenkins/agent.log HTTP/1.1 101已升级的内容类型:应用程序/vnd.docker.原始流连接:升级升级:tcp应用程序版本:1.40码头-实验:错误操作类型:Linux服务器:操作系统(Linux)
错误:启动代理时出现意外错误。这可能是Jenkins中的错误

要重现的基本设置:

Docker模板:

s3fp2yjn

s3fp2yjn1#

几天来一直出现同样的错误。
我们在远程服务器上使用Docker Cloud运行一个Dockerized Jenkins。Jenkins在远程服务器上启动contains,但随后失败,并显示:

Connecting to docker container 32cc538f4287d7aaf11952b6cdcf619d92eb054d7d265ea72a3d7a6bdd1cf8d5, running command java -jar /home/jenkins/remoting-4.6.jar -noReconnect -noKeepAlive -slaveLog /home/jenkins/agent.log
HTTP/1.1 101 UPGRADED
Content-Type: application/vnd.docker.raw-stream
Connection: Upgrade
Upgrade: tcp
Api-Version: 1.40
Docker-Experimental: false
Ostype: linux
Server: Docker/19.03.13 (linux)
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
Also:   java.lang.Throwable: launched here
    at hudson.slaves.SlaveComputer._connect(SlaveComputer.java:283)
    at hudson.model.Computer.connect(Computer.java:435)
    at com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy.start(DockerOnceRetentionStrategy.java:80)
    at com.nirima.jenkins.plugins.docker.strategy.DockerOnceRetentionStrategy.start(DockerOnceRetentionStrategy.java:35)
    at hudson.model.AbstractCIBase.updateComputer(AbstractCIBase.java:162)
    at hudson.model.AbstractCIBase.access$000(AbstractCIBase.java:44)
    at hudson.model.AbstractCIBase$2.run(AbstractCIBase.java:224)
    at hudson.model.Queue._withLock(Queue.java:1401)
    at hudson.model.Queue.withLock(Queue.java:1278)
    at hudson.model.AbstractCIBase.updateComputerList(AbstractCIBase.java:207)
    at jenkins.model.Jenkins.updateComputerList(Jenkins.java:1632)
    at jenkins.model.Nodes$2.run(Nodes.java:139)
    at hudson.model.Queue._withLock(Queue.java:1401)
    at hudson.model.Queue.withLock(Queue.java:1278)
    at jenkins.model.Nodes.addNode(Nodes.java:135)
    at jenkins.model.Jenkins.addNode(Jenkins.java:2155)
    at com.nirima.jenkins.plugins.docker.DockerCloud.robustlyAddNodeToJenkins(DockerCloud.java:445)
    at com.nirima.jenkins.plugins.docker.DockerCloud.access$000(DockerCloud.java:68)
    at com.nirima.jenkins.plugins.docker.DockerCloud$1.run(DockerCloud.java:381)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    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)
java.io.EOFException: unexpected stream termination
    at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:415)
    at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:360)
    at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:425)
    at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:392)
    at io.jenkins.docker.connector.DockerComputerAttachConnector$DockerAttachLauncher.launch(DockerComputerAttachConnector.java:319)
    at hudson.slaves.DelegatingComputerLauncher.launch(DelegatingComputerLauncher.java:64)
    at io.jenkins.docker.connector.DockerDelegatingComputerLauncher.launch(DockerDelegatingComputerLauncher.java:37)
    at hudson.slaves.SlaveComputer.lambda$_connect$0(SlaveComputer.java:294)
    at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
    at jenkins.security.ImpersonatingExecutorService$2.call(ImpersonatingExecutorService.java:80)
    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)
2nc8po8w

2nc8po8w2#

我今天面对了这个错误。
问题出在以下命令上:

${JAVA_EXE}
${JVM_ARGS}
-jar
${FS_DIR}/${JAR_NAME}
-noReconnect
-noKeepAlive
-slaveLog
${FS_DIR}/agent.log

这是Jenkins主服务器为控制节点而执行的命令。问题是slaveLog参数,现在是agentLog吗。我在此Jenkins问题线程(Remote.jar is not working anymore because of changed parameter slave.jar->agent.jar)中发现了该问题。
您可以通过在Docker模板配置中定义入口点CMD并更改错误参数来解决此问题:

${JAVA_EXE}
${JVM_ARGS}
-jar
${FS_DIR}/${JAR_NAME}
-noReconnect
-noKeepAlive
-agentLog
${FS_DIR}/agent.log

在此之后,Jenkins可以管理节点。让我知道是否为您工作了。

快乐大厦

dphi5xsq

dphi5xsq3#

1.将inbound-agent用于Docker映像
1.在代理配置中,将home/jenkins放在字段Remote File System Root中,我遇到了同样的问题,这为我解决了这个问题。

相关问题