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

I am using Docker Pipeline Plugin version 1.10. I have my Jenkins installed in a container. I have a remote server that is running a Docker daemon. The daemon is accessible from the Jenkins machine via TCP (tested). I have disabled TLS security of the Docker daemon. I cannot make docker.withServer (...) work. As a basic test, I just add the following content to the Jenkinsfile (if I'm right, this is valid pipeline content):

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

      

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

Did I miss something? Requires docker command to be installed locally when trying to execute Docker commands on a remote server.?

+6


source to share


2 answers


You tried

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

      



Documentation here

+1


source


docker

must be installed on jenkins master for jenkins to run docker on my.docker.host

.

  • the first command docker

    runs on jenkins master but with a parameter to pass the commandmy.docker.host

  • the container itself will run on my.docker.host



Please note that you only need to install docker

on jenkins master; the daemon should not be running on jenkins master.

0


source







All Articles