Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins pipeline: docker.withServer(...) does not execute docker commands on remote server

I'm using Docker Pipeline Plugin version 1.10. I have my Jenkins installed in a container. I have a remote server that runs a Docker daemon. The daemon is reachable from the Jenkins machine via TCP (tested). I disabled TLS security on the Docker daemon. I'm not able to make the docker.withServer(...) step work. As a basic test I simply put following content in a Jenkinsfile (if I'm correct this is a valid pipeline content):

docker.withServer('tcp://my.docker.host:2345') {
  def myImage = docker.build('myImage')
}

When the pipeline executes I get this error: script.sh: line 2: docker: command not found like the docker command was still trying to execute locally (there is no docker command installed locally) rather than on my remote Docker daemon.

Am I missing anything ? Is it required to have the docker command installed locally when trying to execute Docker commands on a remote server..?

like image 854
stour Avatar asked May 09 '17 07:05

stour


Video Answer


1 Answers

have you tried

withDockerServer('tcp://my.docker.host:2345') {
   .....
}

Documentation here

like image 147
Abhijith Avatar answered Sep 19 '22 14:09

Abhijith