title: Can Docker client(within container) talk to docker daemon on EC2 using UNIX socket?
body: <p>As part of Jenkins docker image, </p>
  
  <p>am supposed to install docker client(only),</p>
  
  <p>that can talk to docker daemon installed on underlying EC2 instance.</p>
  
  <p>UNIX socket, I mean <code>socket(AF_UNIX,,)</code></p>
  
  <hr>
  
  <h1>Background</h1>
  
  <p>As per the instruction, given <a href="https://github.com/jmenga/docker-jenkins/blob/master/Dockerfile#L33" rel="nofollow noreferrer">here</a>, </p>
  
  <p>I do not see the necessity to install docker daemon withink jenkins image,</p>
  
  <p>because the author is using UNIX socket to talk to underlying docker daemon running in EC2 instance, as shown <a href="https://github.com/jmenga/docker-jenkins/blob/master/docker-compose.yml#L17" rel="nofollow noreferrer">here</a>. </p>
  
  <p>My understanding is, installing docker client installation(only) within jenkins image, would suffice to talk to docker daemon running on EC2 instance, using UNIX socket(<code>/var/run/docker.sock</code>)</p>
  
  <hr>
  
  <p>1)</p>
  
  <p>Can docker client running in jenkins image communicate to docker daemon running in underlying EC2 instance?  with below mapping...</p>
  
  <pre><code>volumes:
      - /var/run/docker.sock:/var/run/docker.sock
  </code></pre>
  
  <p>2)</p>
  
  <p>How to install docker client only in below jenkins image?</p>
  
  <pre><code>FROM jenkins:1.642.1
  
  
  # Suppress apt installation warnings
  ENV DEBIAN_FRONTEND=noninteractive
  
  # Official Jenkins image does not include sudo, change to root user
  USER root
  
  # Used to set the docker group ID
  # Set to 497 by default, which is the groupID used by AWS Linux ECS instance
  ARG DOCKER_GID=497
  
  # Create Docker Group with GID
  # Set default value of 497 if DOCKER_GID set to blank string by Docker compose
  RUN groupadd -g ${DOCKER_GID:-497} docker
  </code></pre>