2

I want to create a automatic docker image through Jenkins once build got success.

I tried by providing docker commands in execute shell but throwing command not found error.If this is not right way how to achieve this in Windows 10.

Shell

Error:

................    
................
  12 passing (81ms)

+ docker build -t snapshot .
C:\WINDOWS\TEMP\jenkins6038297422360146327.sh: line 4: docker: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Even after installing docker inside jenkins it is not picking my docker url

Docker inside jenkins

Docker Inside Jenkins

Complete error of Docker URL

enter image description here

Created a new vm with TLS false:

docker-machine create -d virtualbox --engine-opt tlsverify=false node2

to check TLS is made false i ran below command

 docker-machine env node2

enter image description here

here DOCKER_TLS_VERIFY = "1",however in the documentation it is mentioned DOCKER_TLS_VERIFY = "0" should be zero whether my machine now TLS enabled or not how can i confirm my machine is TLS false??

rselvaganesh
  • 1,032
  • 2
  • 18
  • 30

3 Answers3

1

The shell you configured in your Jenkins job is executed by Jenkins executor on Jenkins machine(or Jenkins Slave machine if you're using Jenkins the Master-Slave way), so whatever command you would like to use, it must be installed correctly and in the PATH of the target machine, just like you execute command on terminal manually.

So the error message is self-explained now:

C:\WINDOWS\TEMP\jenkins6038297422360146327.sh: line 4: docker: command not found

which means you have not installed docker on your Jenkins machine, you need to install and configure it firstly.

Additionally, you may want to have a look at Docker build step plugin for Jenkins.

shizhz
  • 11,715
  • 3
  • 39
  • 49
  • i have configured docker inside Jenkins using docker-plugin it requires a docker url where i have specified my url as tcp://192.168.99.100:2376,but it is not considering my url but docker demon is running – rselvaganesh Apr 12 '17 at 09:04
  • i have added image above question, even i tried docker inside jenkins – rselvaganesh Apr 12 '17 at 09:08
  • If you're using `Docker build step plugin`, you don't run `docker `command in shell, you need to use build steps provided by this plugin I think, checkout `Add build step` to see what you can find. – shizhz Apr 12 '17 at 09:21
  • yeah i understood the point which u said,on the following tutorial it is mentioned to give shell scripts...i have followed this step to config https://www.katacoda.com/courses/jenkins/build-docker-images but why my tcp is not connecting with jenkins docker cloud??do you have any idea why this error occurs?? @shizhz – rselvaganesh Apr 12 '17 at 09:34
  • I have updated my question with screen shot for that error i followed below troubleshooting but again its a bad luck:( http://stackoverflow.com/questions/32099532/accessing-docker-host-from-jenkins-docker-container @shizhz – rselvaganesh Apr 12 '17 at 09:47
  • Em...is the machine you run `docker-machine` the same with the on you run Jenkins? It's complaining that http header is not valid, did you tried to disable `tls` by `--tls=false`, restart your docker and try again? – shizhz Apr 12 '17 at 10:04
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/141556/discussion-between-rselvaganesh-and-shizhz). – rselvaganesh Apr 12 '17 at 13:12
  • i tried to create a new docker vm with tls false my command is docker-machine create -d virtualbox --engine-opt tls=false default.is this correct?how to confirm my machine is TLS false or not – rselvaganesh Apr 12 '17 at 13:17
  • above i have edited with tls image could you please see and reply @shizhz – rselvaganesh Apr 12 '17 at 13:33
  • @rselvaganesh, sorry for late response, I'm not very familiar with docker-machine, could http://stackoverflow.com/questions/30717347/docker-machine-create-node-without-tls-verification and https://coderwall.com/p/siqnjg/disable-tls-on-boot2docker be helpful to you? Besides you can try with docker http api, like `curl http://://containers/json` to see what's the response, and also try `https`. – shizhz Apr 13 '17 at 03:27
0

install docker on jenkins. Jenkins does not know about docker.

Meiram Chuzhenbayev
  • 898
  • 1
  • 10
  • 26
0

If you don't need to run Docker on the same server than Jenkins I found that downloading a Docker Client was better than using the Jenkins Plugin. You can find the latest version here: https://download.docker.com/win/static/stable/x86_64/

Then just call the docker command with --host 192.168.99.100. It should work and build the image on the Docker Server 192.168.99.100

Guillaume
  • 423
  • 1
  • 4
  • 11