<p>We are running a Kubernetes cluster for building Jenkins jobs. For the pods we are using the <strong>odavid/jenkins-jnlp-slave</strong> JNLP docker image. I mounted the /var/run/docker.sock to the pod container and added jenkins(uid=1000) user to the docker group on the host systems.</p>
<p>When running a shell script job in Jenkins with e.g. <code>docker ps</code> it fails with error <code>docker: not found</code>.</p>
<pre><code>$ /bin/sh -xe /tmp/jenkins6501091583256440803.sh
+ id
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins)
+ docker ps
/tmp/jenkins2079497433467634278.sh: 8: /tmp/jenkins2079497433467634278.sh: docker: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
</code></pre>
<p>The interesting thing is that when connecting into the pod manually and executing docker commands directly in the container as jenkins user, it works:</p>
<pre><code>kubectl exec -it jenkins-worker-XXX -- /bin/bash
~$ su - jenkins
~$ id   
uid=1000(jenkins) gid=1000(jenkins) groups=1000(jenkins),1000(jenkins)
~$ docker ps 
CONTAINER ID        IMAGE        COMMAND         CREATED         STATUS
</code></pre>
<p>What is doing Jenkins in its job differently? Same user, same container, only <code>groups=1000(jenkins),1000(jenkins)</code> lists 1000(jenkins) as group 2 times when connecting manually. What am i missing?</p>

<p>/var/run/docker.sock is just the host socket that allows docker client to  run  docker commands from the container.</p>
<p><strong>What you are missing is the docker client in your container.</strong></p>
<p>Download the docker client manually and place it on a persistent volume and ensure that he docker client is in the system path. Also, ensure that the docker client is executable.</p>
<p>This command will do it  for you.  You may have to get the right version of the docker client for your environment</p>
<pre><code>curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-17.03.1-ce.tgz &amp;&amp;
tar --strip-components=1 -xvzf docker-17.03.1-ce.tgz -C /usr/local/bin
</code></pre>
<p>You may even be able to install the  docker using the  package manager for your image.</p>
