'docker: not found' Error when building a docker image

262 views
Skip to first unread message

Desmond Lim

unread,
Feb 6, 2021, 1:44:19 PM2/6/21
to Jenkins Users
Hi All,

I am trying to build a docker image inside a Jenkins pod.  However, I got the below errors.  When I login to the Jenkins pod, I cannot find the docker command.  I have installed all plugins related to Jenkins and am using 'jenkins/jenkins:lts' image from docker hub.  

[docker-demo] $ /bin/sh -xe /tmp/jenkins2842149568243187838.sh + docker build . -t anandr72/nodeapp /tmp/jenkins2842149568243187838.sh: 2: /tmp/jenkins2842149568243187838.sh: docker: not found Build step 'Execute shell' marked build as failure Finished: FAILURE

Appreciate if someone can help.  Thanks.  

Mark Waite

unread,
Feb 6, 2021, 4:26:39 PM2/6/21
to Jenkins Users
https://dev.to/thakkaryash94/how-many-ways-to-build-a-container-image-4g3p suggests several different ways that a Kubernetes pod can be used to build a container with using the docker command.

It also provides a nice summary of the risks of using the docker command to build untrusted images.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/31b7fa45-4b80-43b6-a83b-0d4c1417e010n%40googlegroups.com.

Desmond Lim

unread,
Feb 7, 2021, 1:11:19 AM2/7/21
to jenkins...@googlegroups.com
Hi Mark,

Thanks for the responds.  However, I cannot find any Jenkins plugins for the solutions proposed in the link. 
Apologizes as I am a newbie in DevOps.  

I am thinking either to use a Jenkin's free style project or Pipeline to build a image and then push the image to docker hub.  In this case, the tool to build the images must either reside within the Jenkins pod or needs to be installed in another pod(I am looking at Kaniko/Podman) .  Is this understanding correct?

Thanks.  




--
Best Regards,
Desmond Lim

Mark Waite

unread,
Feb 7, 2021, 12:00:16 PM2/7/21
to Jenkins Users
On Saturday, February 6, 2021 at 11:11:19 PM UTC-7 dke wrote:
Hi Mark,

Thanks for the responds.  However, I cannot find any Jenkins plugins for the solutions proposed in the link. 
Apologizes as I am a newbie in DevOps.  

I am thinking either to use a Jenkin's free style project or Pipeline to build a image and then push the image to docker hub.  In this case, the tool to build the images must either reside within the Jenkins pod or needs to be installed in another pod(I am looking at Kaniko/Podman) .  Is this understanding correct?

Yes, your understanding is correct.  The tool to build the image will need to be available on the agent where the build is run.

The general direction in Jenkins projects is to prefer a Pipeline project rather than a Freestyle project so that you can control the job definition from source code rather than controlling the job definition from the Jenkins user interface.  If you use a Pipeline project, you avoid the need for a plugin to invoke the container builder for you.  You invoke the container builder from the `sh` step.

Mark Waite
 

Thanks.  


On Sun, 7 Feb 2021 at 05:26, Mark Waite wrote:
https://dev.to/thakkaryash94/how-many-ways-to-build-a-container-image-4g3p suggests several different ways that a Kubernetes pod can be used to build a container with using the docker command.

It also provides a nice summary of the risks of using the docker command to build untrusted images.

On Sat, Feb 6, 2021 at 11:44 AM Desmond Lim wrote:
Hi All,

I am trying to build a docker image inside a Jenkins pod.  However, I got the below errors.  When I login to the Jenkins pod, I cannot find the docker command.  I have installed all plugins related to Jenkins and am using 'jenkins/jenkins:lts' image from docker hub.  

[docker-demo] $ /bin/sh -xe /tmp/jenkins2842149568243187838.sh + docker build . -t anandr72/nodeapp /tmp/jenkins2842149568243187838.sh: 2: /tmp/jenkins2842149568243187838.sh: docker: not found Build step 'Execute shell' marked build as failure Finished: FAILURE

Appreciate if someone can help.  Thanks.  


--
Best Regards,
Desmond Lim
Reply all
Reply to author
Forward
0 new messages