Use Jenkins Docker plugin in the Kubernetes cluster on Gke

I followed this great tutorial to install Jenkins on my GKE kubernetes cluster and then started using CI.
Everything went well until I tried to use it in my pipeline docker plugin.

This is the link I added to the issue in the github project I referenced:

https://github.com/GoogleCloudPlatform/continuous-deployment -on-kubernetes/issues/65

When I try to use a docker plugin like this:

stage "Prepare environment"
docker. image('node:4.1.2').inside {
print "inside a node server"
sh("echo test");
//sh("npm install");
}

I received the following error:

[Pipeline] stage (Prepare environment)
Using the'stage' step without a block argument is deprecated
Entering stage Prepare environment
Proceeding
[Pipeline] sh
[play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA] Running shell script
docker inspect -f. node:4.1.2
.
[Pipeline] withDockerContainer
$docker run -t -d -u 0:0 -w /root/workspace/play_PLR-437- jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YS VATI3UYUBXA -v / root / workspace / play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA: / root / workspace / play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA: rw -v / root / workspace / play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA @tmp:/root/workspace/play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA@tmp:rw -e ******** -e ******** -e ******* * -e ******** -e ******** -e ******** -e ******** -e ******* * -e ******** -e ******** -e ******** -e ******** -e ******* * -e ******** -e ******** -e ******** -e ******** -e ******* * -e ******** -e ******** --entrypoint cat node:4.1.2
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image'node:4.1.2'. Error: docker: Error response from daemon: mkdir /root/workspace: read-only file system.
at org.jenkinsci.plugins.docker.workflow. client.DockerClient.run(DockerClient.java:125)
at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java:175)
at org.jenkinsci.plugins. workflow.cps.DSL.invokeStep(DSL.java:184)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
at org.jenkinsci.plugins. workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
at org.codehaus.groovy. runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy. cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar:file:/var/jenkins_home/plugins/docker-workflow/ WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:1 22)
at org.jenkinsci.plugins.docker.workflow.Docker.node(jar:file:/var/jenkins_home/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org /jenkinsci/plugins/docker/workflow/Docker.groovy:63)
at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar:file:/var/jenkins_home/plugins/docker-workflow /WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:116)
at WorkflowScript.run(WorkflowScript:12)
at ___cps. transform___(Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg (FunctionCallBlock.java:109)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
at sun.reflect.GeneratedMethodAccessor382.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpluation.receive(ContinuationPtr. java:72)
at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
at com.cloudbees.groovy.cps.Next.step(Next.java: 58)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18 )
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java :30)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable .java:30)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThre ad.java:163)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100 (CpsThreadGroup.java:80)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2 .call(CpsThreadGroup.java:228)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
at java.util.concurrent.FutureTask.run( FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
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.jav a:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

Basically this:

java.io.IOException: Failed to run image'node:4.1.2'. Error: docker: Error response from daemon: mkdir /root/workspace: read-only file system.

Do more investigation in the link I specified above.
In this case, use docker in docker It seems tricky.
I am new to jenkins, but I guess it must be a way to make the docker plugin work in this situation (GKE kubernetes cluster)

Thanks a lot in advance

Philip

I use the Jenkins plugin to stay away from the dock “abstraction”. You can execute the shell directly Command to execute docker workload, for example:

sh "docker build -t $SOME_NAME:$GIT_COMMIT_SHA ."
sh "docker run .."

Or more specifically your paste:

sh "docker run -d --name node node:4.1.2"
sh "docker exec -it node /bin/sh -c'npm install'"

I followed this great tutorial to install Jenkins on my GKE kubernetes cluster , And then started using CI.
Everything went well until I tried to use the docker plugin in my pipeline.

This is the question I added to the github project I referenced Link to the question:

https://github.com/GoogleCloudPlatform/continuous-deployment-on-kubernetes/issues/65

When I try to use such a docker plugin:< /p>

stage "Prepare environment"
docker.image('node:4.1.2').inside {
print "inside a node server"
sh("echo test");
//sh("npm install");
}

I received the following error:

< /p>

[Pipeline] stage (Prepare environment)
Using the'stage' step without a block argument is deprecated
Entering stage Prepare environment
Proceeding
[Pipeline] sh
[play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA] Running shell script
+ docker inspect -f. node:4.1.2
.
[Pipeline] withDockerContainer
$docker run -t -d -u 0:0 -w /root/workspace/play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA -v /root/workspace/play_PLR-437-jenkins-workspace/play_PLR-437-jenkins-web /play_PLR-437-jenkins-confi g-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA: rw -v / root / workspace / play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA @ tmp: / root / workspace / play_PLR-437-jenkins-config-WQ5IB66PEGACJNE6UHFF54RVEEBWEEDWRSVCZM3YSVATI3UYUBXA @ tmp: rw -e ****** ** -e ******** -e ******** -e ******** -e ******** -e ****** ** -e ******** -e ******** -e ******** -e ******** -e ****** ** -e ******** -e ******** -e ******** -e ******** -e ****** ** -e ******** -e ******** -e ******** -e ******** --entrypoint cat node:4.1. 2
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.IOException: Failed to run image'node:4.1.2'. Error: docker: Error response from daemon: mkdir /root/workspace: read-only file system.
at org.jenkinsci.plugins.docker.workflow.client.DockerClient .run(DockerClient.java:125)
at org.jenkinsci.plugins.docker.workflow.WithContainerStep$Execution.start(WithContainerStep.java: 175)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:184)
at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java: 126)
at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java: 48)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java: 113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar: file:/var/jenkins_home/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:122)
at org.jenkinsci .plugins.docker.workflow.Docker.node(jar:file:/var/jenkins_home/plugins/docker-workflow/WEB-INF/lib/docker-workflow.jar!/org/ jenkinsci/plugins/docker/workflow/Docker.groovy:63)
at org.jenkinsci.plugins.docker.workflow.Docker$Image.inside(jar:file:/var/jenkins_home/plugins/docker-workflow/ WEB-INF/lib/docker-workflow.jar!/org/jenkinsci/plugins/docker/workflow/Docker.groovy:116)
at WorkflowScript.run(WorkflowScript:12)
at ___cps.transform___ (Native Method)
at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg( FunctionCallBlock.java:109)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
at sun.reflect.GeneratedMethodAccessor382.invoke(Unknown Source)< br /> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy. cps.impl.ContinuationPtr$ContinuationImpl.rece ive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
at com.cloudbees.groovy.cps.Next.step( Next.java:58)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable .java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:33)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call (SandboxContinuable.java:30)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable .run0(SandboxContinuable.java:30)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup .run(CpsThreadGroup.java:328)
at org.jenkinsci.plugins.workflow.cps.Cps ThreadGroup.access$100(CpsThreadGroup.java:80)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
at org.jenkinsci.plugins.workflow. cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
at java.util.concurrent. FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
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:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run (Thread.java:745)
Finished: FAILURE

Basically this:

java.io.IOException: Failed to run image'node:4.1.2'. Error: docker : Error response from daemon: mkdir /root/workspace: read-only file system.

Do more investigation in the link I specified above.
In this case, use it in docker Docker seems to be tricky.
I am new to jenkins, but I guess it must be a way to make the docker plugin work in this situation (GKE kubernetes cluster)

Thanks in advance

p>

Philip

I use the Jenkins plugin to stay away from the docker “abstraction”. You can directly execute shell commands to execute docker workloads, for example:

sh "docker build -t $SOME_NAME:$GIT_COMMIT_SHA ."
sh "docker run .."

Or more specifically Said it was your paste:

sh "docker run -d --name node node:4.1.2"
sh "docker exec -it node /bin/ sh -c'npm install'"

Leave a Comment

Your email address will not be published.