2
votes

I've got a slave running in a jenkins pipeline. The slave image has a recent version of docker, but the server version is very old. I can't tell how Jenkins launches the container or what jenkins is using for a docker server. I've created a very simple jenkins file:

#!/usr/bin/groovy

podTemplate(label: 'jenkins-pipeline', 
    containers: [
        containerTemplate(name: 'jnlp', image: 'myrepo/jnlp-docker:2.0')
    ],
    volumes:[
        hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
    ]){
    node ('jenkins-pipeline') {
        sh("docker version")    
   }
}

The output of that "docker version" command is:

Client:
  Version:      18.03.1-ce
  API version:  1.26 (downgraded from 1.37)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:17:14 2018
  OS/Arch:      linux/amd64
  Experimental: false
  Orchestrator: swarm

Server:
  Engine:
    Version:      1.13.1
    API version:  1.26 (minimum version 1.12)
    Go version:   go1.7.5
    Git commit:   092cba3
    Built:        Wed Feb  8 06:36:34 2017
    OS/Arch:      linux/amd64
    Experimental: false

So where is that Server version 1.13.1 coming from? How do I upgrade Jenkins to use a more recent version?

EDIT. programmerq had the solution below, but I'll add specifics here. Jenkins was running as a kubernetes container and didn't have docker installed, but Jenkins somehow shares the docker daemon from the Kubernetes host node through to the Jenkins Pipeline slave container. My kubernetes cluster (running on AWS, created with kops) comes with an old version of docker by default. I had to update my kubernetes cluster with a higher docker version. Steps are

kops edit cluster 

#kops edit cluster opens vi.  Add docker property as shown below and save
spec:
  docker: #add docker config
    logDriver: json-file #required property.  Errors out when missing
    version: 17.09.0 #caution, only specific docker versions are supported

kops update cluster
kops rolling-update cluster --yes
1

1 Answers

2
votes

It appears that you are sharing the /var/run/docker.sock from the jenkins host into the container.

When your 18.03.1-ce docker client connects to that /var/run/docker.sock socket, it is talking to the dockerd running on the jenkins host.

If you wish to upgrade that docker daemon, you should follow the instructions for docker install/upgrade relevant for the platform that jenkins is running on.

Once you upgrade the host's dockerd, your docker client inside the container will see whatever version you end up installing.