简体   繁体   English

构建 docker 容器时 Kubernetes 上的 Jenkins 问题

[英]Issue with Jenkins on Kubernetes when building docker containers

I have setup jenkins to run on GKE kubernetes cluster.我已经设置 jenkins 在 GKE kubernetes 集群上运行。 I wrote the Jenkinsfile to define CI/CD pipeline.我编写了 Jenkinsfile 来定义 CI/CD 管道。 But when it reaches the docker build command, it gives me the following error: "Segmentation fault (core dumped) Build step 'Execute shell' marked build as failure Finished: FAILURE"但是当它到达 docker 构建命令时,它给了我以下错误:“分段错误(核心转储)构建步骤'执行外壳'标记构建为失败完成:失败”

After that I setup a new test job and run random command and it executes successfully but when I run docker version, I get the same error.之后我设置了一个新的测试作业并运行随机命令并且它成功执行但是当我运行 docker 版本时,我得到了同样的错误。 The error comes when I run docker commands.当我运行 docker 命令时出现错误。 I have restarted my jenkins pod, freshly setup a new jenkins instance on the cluster but the error was still there.我已经重新启动了我的 jenkins pod,在集群上新设置了一个新的 jenkins 实例,但错误仍然存在。 I need help.!我需要帮助。! Any feedback is much appreciated.非常感谢任何反馈。

Regards,问候,

The reason you are having an issue is because you are trying to run docker inside a container.您遇到问题的原因是您尝试在容器内运行 docker。 The Jenkins pod(s) are themselves running in a container (docker or otherwise) inside the kubernetes cluster. Jenkins pod(s) 本身在 kubernetes 集群内的容器(docker 或其他)中运行。 It can be very tricky to run docker inside a container.在容器内运行 docker 可能非常棘手。 There is a lot of help out there on how to do it - search for "docker in docker" or "dind", but there are a lot of reasons you do not want to do that.关于如何做到这一点有很多帮助 - 搜索“docker in docker”或“dind”,但有很多原因你不想这样做。 Security being a big issue here.安全是这里的一个大问题。

Instead, you may consider some other way to build your container images, without using a docker command.相反,您可以考虑使用其他方法来构建容器映像,而不使用 docker 命令。 Search for "building containers without docker" or something similar.搜索“在没有 docker 的情况下构建容器”或类似内容。 My favourite is to use kaniko .我最喜欢的是使用kaniko Kaniko avoids the issues of running docker inside a container, and is compatible with the same Dockerfile you already use. Kaniko 避免了在容器内运行 docker 的问题,并且与您已经使用的相同 Dockerfile 兼容。

There are other ways to do this as well.还有其他方法可以做到这一点。 Searching will give some good results.搜索会得到一些好的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Jenkins 中构建时未找到 docker - docker not found when building in Jenkins 通过jenkins在kubernetes上部署docker映像的问题 - issue in deploying docker image on kubernetes through jenkins 在 jenkins 管道中,在 azure kubernetes 服务的 Kubernetes pod 中执行 docker build 时,unix 上出现问题 Docker 守护进程套接字 - In jenkins pipeline getting issue Docker daemon socket at unix when doing docker build in Kubernetes pod of azure kubernetes services Docker容器作为Jenkins从站 - Docker Containers as Jenkins Slave 使用Jenkins运行Docker容器 - Run Docker containers with Jenkins 使用Jenkins和Docker进行构建时“设备上没有剩余空间” - “no space left on device” when building with Jenkins and Docker 在 Docker 插件中构建 Jenkins 时安装失败 - When building Jenkins in Docker plugins fail to install 当 Kubelet 停止时,Docker 可以自动终止 Kube.netes worker 上的容器吗? - Can Docker automatically kill containers on a Kubernetes worker when Kubelet stopped? 在 Windows 上构建容器时,Docker 构建变量始终为空 - Docker build variables are always empty when building containers on Windows 构建 Docker 容器时,从私有源恢复 NuGet 包 - Restore NuGet Packages from a Private Feed when building Docker Containers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM