<p>In Jenkins, I want to understand why &quot;docker ps&quot; is not running inside my container despite I redact my Jenkins file like this :</p>
<pre><code>podTemplate(serviceAccount: 'jenkins', containers: [ 
    containerTemplate(
      name: 'docker', 
      image: 'docker', 
      resourceRequestCpu: '100m',
      resourceLimitCpu: '300m',
      resourceRequestMemory: '300Mi',
      resourceLimitMemory: '500Mi',
      command: 'cat', 
      privileged: true,
      ttyEnabled: true
    )
  ],

  volumes: [
    hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
  ]
  ) {
    node(POD_LABEL) {

        stage('Check running containers') {
            container('docker') {  
                sh 'hostname'
                sh 'hostname -i' 
                sh 'docker --version'
                sh 'docker ps'
            }
}
</code></pre>
<p>I have always this kind of message after I start my pipeline :
unix:///var/run/docker.sock.</p>
<p>Is the docker daemon running?
Thanks</p>
<p>It must have something like the result of a PS running with docker command.</p>

slim_wn
<p>Even if you run Jenkins inside a docker container, you must install docker inside.</p>
<p>Best way create a new Dockerfile and install docker inside.</p>
<pre><code>FROM jenkins/jenkins

ARG HOST_UID=1004
ARG HOST_GID=999

USER root
RUN apt-get -y update &amp;&amp; \
    apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common &amp;&amp; \
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - &amp;&amp; \
    add-apt-repository &quot;deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo &quot;$ID&quot;) $(lsb_release -cs) stable&quot; &amp;&amp; \
    apt-get update &amp;&amp; \
    apt-get -y install docker-ce docker-ce-cli containerd.io
RUN curl -L &quot;https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)&quot; -o /usr/local/bin/docker-compose  \
    &amp;&amp; chmod +x /usr/local/bin/docker-compose  \
    &amp;&amp; ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose \
    &amp;&amp; curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - 
RUN echo &quot;deb https://apt.kubernetes.io/ kubernetes-xenial main&quot; | tee /etc/apt/sources.list.d/kubernetes.list \
    &amp;&amp; apt-get -y update \
    &amp;&amp; apt install -y kubectl

RUN usermod -u $HOST_UID jenkins
RUN groupmod -g $HOST_GID docker
RUN usermod -aG docker jenkins

USER jenkins
</code></pre>
<p>For the sake of clarity if you deploy to Kubernetes or use docker-compose, you will need also kubectl and docker-compose inside your container. If not you can remove the installation from Dockerfile above.</p>
