0

I have installed Jenkins and Docker ToolBox on same machine running on Windows 7 . While running Jenkins build, all the commands work fine except docker. When I try to run the docker command in build step using Jenkins, it gives me error.

E:\Jenkins\workspace\docker-app>docker build -t docker-app.
'docker' is not recognized as an internal or external command, operable program or batch file.

But the same command works fine for windows command prompt. Any help would be much appreciated.

4 Answers4

1

I had exactly same issues until i added docker path to system variable

enter image description here

enter image description here

overflowed
  • 1,095
  • 1
  • 18
  • 39
0

add the path command to your jJenkins job , make sure it includes docker

Mor Lajb
  • 2,546
  • 1
  • 15
  • 28
  • Hi Mor, Thanks for your help. I have tried it and it also does not work. Any other suggestions?? – Ezio_Auditore Sep 04 '17 at 08:43
  • did you add the path of the docker installation , and Jenkins still can't run docker commands ? – Mor Lajb Sep 04 '17 at 09:32
  • Yes, I added the path of the docker installation and from command prompt everything works fine. But when I try it through the Jenkins build step, it fails. – Ezio_Auditore Sep 04 '17 at 10:18
  • so try to add the docker installation path , as part of you jenkins build. export path=path;dokcer_path ... , don't remember the exact windows format – Mor Lajb Sep 04 '17 at 10:21
0

As per your description it seems to me that,

  • You have windows 7 machine with docker toolbox installed.
  • You are running Jenkins inside one of container?
  • If yes then you won't able to run docker commands from Jenkins box.

    Because You are running Jenkins inside Docker container and Docker is not installed in your docker container that's why it will throw error as 'docker' is not recognized as an internal or external command, operable program or batch file and which is right.

To get this working you need to install Docker inside your docker container that concept is called "Docker-in-Docker".

If you need any help/clarification regarding this then please let me know.

Rohan J Mohite
  • 2,283
  • 10
  • 19
  • Hi Rohan, Thanks for your answer. But I am not running jenkins inside docker container. Jenkins is also installed on windows and docker is also installed on windows. If you need any other information, please let me know. Thanks!! – Ezio_Auditore Sep 04 '17 at 08:42
  • How you are communicating with docker host (docker toolbox) from Jenkins? On Windows 7, do you have another virtual ubuntu machine for Jenkins? – Rohan J Mohite Sep 04 '17 at 15:46
0

i came across the same issue some time back, hope it will help anyone down the line
even adding docker toolbox in the environment variables didn't work for me
this is what i did
1) go to jenkins --> Manage Jenkins --> configure system

2) go to Global properties section

3) add the following environment variables
   a) DOCKER_CERT_PATH = C:\Users\%USER%.docker\machines\default
   b) DOCKER_HOST = tcp://192.168.99.XX:2376 ( it might be different in your case )
   c) DOCKER_MACHINE_NAME = default
   d) DOCKER_TLS_VERIFY = 1

if the problem still persists after the above changes

4) add git binary path to environment variables system path
  a) in my case it was C:\Program Files\Git\usr\bin

Abhishek D K
  • 2,257
  • 20
  • 28