title: Access docker.sock from inside a container
body: <p>I'm running a jenkins docker container from which I need to build and run dockers. The container is started using <code>-v /var/run/docker.sock:/var/run/docker.sock</code>.
  The problem is that I'm getting access denied when jenkins (from inside the container) tries to use it.</p>
  
  <p>This is what I've tried so far with no luck:</p>
  
  <ul>
  <li>Create a jenkins user in the host and add it to the docker group. </li>
  <li>Start the docker daemon with the <code>-G jenkins</code> parameter so the socket is owned by the jenkins group instead of the docker one. Jenkins is being executed with a jenkins user that belongs to a jenkins group inside the container.</li>
  </ul>
  
  <p>The only thing that worked was a "hack" that I don't like at all: I've modified the id of the jenkins group inside the container to match the group id of <code>docker.sock</code>.</p>
  
  <p>Any suggestion on how to solve this in a more elegant way would be appreciated.</p>