When running this simple declarative pipeline script:
my jenkins fails with the error message:
Caused: java.io.IOException: Cannot run program "docker": error=2, No such file or directory
The first call to docker works fine. It downloads the image and is able to call:
inspect -f . ruby
The following code path fails:
The docker client launches docker like this:
As we can see here it instantiates a new EnvVars object. This passed down to the launch method.
In my case this fails because the docker executable is not in the path by default. I updated the path on the Jenkins Configuration (which works because I can use docker to download the image).
I can only solve this issue at the moment by having docker in the PATH during startup of Jenkins. Setting the tool location also yielded no result because the toolName passed to DockerClient is always null (step.toolName). I couldn't figure out the magic incantation to get the DockerTool locator to work in a declarative pipeline (org.jenkinsci.plugins.docker.commons.tools.DockerTool).