0
votes

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

4 Answers

1
votes

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

enter image description here

enter image description here

0
votes

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

0
votes

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.

0
votes

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