<p>I have setup jenkins to run on GKE kubernetes cluster. I wrote the Jenkinsfile to define CI/CD pipeline. 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"</p>

<p>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. The error comes when I run docker commands. I have restarted my jenkins pod, freshly setup a new jenkins instance on the cluster but the error was still there. I need help!! Any feedback is much appreciated.</p>

<p>Regards,</p>

<p>The reason you are having an issue is because you are trying to run docker inside a container. The Jenkins pod(s) are themselves running in a container (docker or otherwise) inside the kubernetes cluster. It can be very tricky to run docker inside a container. 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. Security being a big issue here.</p>

<p>Instead, you may consider some other way to build your container images, without using a docker command. Search for "building containers without docker" or something similar. My favourite is to use <a href="https://github.com/GoogleContainerTools/kaniko" rel="nofollow noreferrer">kaniko</a>. Kaniko avoids the issues of running docker inside a container, and is compatible with the same Dockerfile you already use.</p>

<p>There are other ways to do this as well. Searching will give some good results.</p>
