title: Unable to connect to docker.sock when it exist with permissions running inside docker container
body: <p>I'm setting up a base image that has docker installed and configured so when I run my jenkins pipeline I can do anchore scanning. I have to pull the anchore image inside the docker image because my pipeline is running on a docker agent. However, even running locally trying to build a docker image and just run a simple hello-world docker container or do a docker pull fails to connect to the docker socket. I added the root user to the docker group, I even chmod 777 and a+xX to the docker.sock. For some reason its in both /run/docker.sock and /var/run/docker.sock it seems it gets symlinked. I'm using ubuntu:18.04-bionic release to build from and installing from the ubuntu repository. The Ubuntu image doesn't have systemd installed and when I install systemd it says it wasn't started with boot which means it has to be installed on boot when the image starts up. I start it with service docker start.</p>
  
  <pre><code>Processing triggers for libc-bin (2.27-3ubuntu1) ...
  Processing triggers for dbus (1.12.2-1ubuntu1) ...
  /usr/bin/docker
  /usr/share/bash-completion/completions/docker
  /etc/init.d/docker
  /etc/default/docker
  /etc/docker
   * Starting Docker: docker
     ...done.
  /run/docker.sock
  total 32K
  drwxr-xr-x 1 root    root    4.0K Oct 31 17:49 .
  drwxr-xr-x 1 root    root    4.0K Oct 31 17:49 ..
  drwxr-xr-x 2 dnsmasq nogroup 4.0K Oct 31 17:49 dnsmasq
  drwx------ 4 root    root    4.0K Oct 31 17:49 docker
  -rw-r--r-- 1 root    root       6 Oct 31 17:49 docker-ssd.pid
  srwxrwxrwx 1 root    docker     0 Oct 31 17:49 docker.sock
  drwxrwxrwt 2 root    root    4.0K Oct 18 21:02 lock
  drwxr-xr-x 2 root    root    4.0K Oct 18 21:02 mount
  drwxr-xr-x 2 root    root    4.0K Oct 19 00:47 systemd
  -rw-rw-r-- 1 root    utmp       0 Oct 18 21:02 utmp
  total 32K
  drwxr-xr-x 1 root    root    4.0K Oct 31 17:49 .
  drwxr-xr-x 1 root    root    4.0K Oct 31 17:49 ..
  drwxr-xr-x 2 dnsmasq nogroup 4.0K Oct 31 17:49 dnsmasq
  drwx------ 4 root    root    4.0K Oct 31 17:49 docker
  -rw-r--r-- 1 root    root       6 Oct 31 17:49 docker-ssd.pid
  srwxrwxrwx 1 root    docker     0 Oct 31 17:49 docker.sock
  drwxrwxrwt 2 root    root    4.0K Oct 18 21:02 lock
  drwxr-xr-x 2 root    root    4.0K Oct 18 21:02 mount
  drwxr-xr-x 2 root    root    4.0K Oct 19 00:47 systemd
  -rw-rw-r-- 1 root    utmp       0 Oct 18 21:02 utmp
  docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
  See 'docker run --help'.
  </code></pre>
  
  <p>My Dockerfile</p>
  
  <pre><code>FROM ubuntu:bionic
  
  #requirements
  #docker
  #kubectl
  #terraform
  #kops
  #mysql
  #systemd
  
  
  ENV DEBIAN_FRONTEND=noninteractive \
      NVM_VERSION=0.33.11 \
      NODE_VERSION=9.11.1
  
  RUN set -e &amp;&amp; \
      echo "NODE_VERSION: $NODE_VERSION" &amp;&amp; \
      apt-get update --yes &amp;&amp; \
      apt-get install git \
                      gnupg \
                      wget \
                      curl \
                      apt-utils \
                      gcc \
                      g++ \
                      make \
                      build-essential \
                      nginx \
                      python \
                      vim \
                      gnupg \
                      gnupg2 \
                      net-tools \
                      software-properties-common \
                      npm \
                      curl \
                      libxss1 \
                      libappindicator1 \
                      libindicator7 \
                      apt-utils \
                      fonts-liberation \
                      xfonts-cyrillic \
                      xfonts-100dpi \
                      xfonts-75dpi \
                      xfonts-base \
                      xfonts-scalable \
                      libappindicator3-1 \
                      libasound2 \
                      libatk-bridge2.0-0 \
                      libgtk-3-0 \
                      libnspr4 \
                      libnss3 \
                      libx11-xcb1 \
                      libxtst6 \
                      xdg-utils \
                      lsb-release \
                      xvfb \
                      python-pip \
                      default-jre \
                      gtk2-engines-pixbuf -y &amp;&amp; \
      wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &amp;&amp; \
      dpkg -i google-chrome*.deb &amp;&amp; \
      NVM_DIR="$HOME/.nvm" &amp;&amp; \
      PROFILE="$HOME/.profile" &amp;&amp; \
      git clone --branch "v$NVM_VERSION" --depth 1 https://github.com/creationix/nvm.git "$NVM_DIR" &amp;&amp; \
      echo &gt;&gt; "$PROFILE" &amp;&amp; \
      echo 'export NVM_DIR="$HOME/.nvm"' &gt;&gt; "$PROFILE" &amp;&amp; \
      echo '[ -s "$NVM_DIR/nvm.sh" ] &amp;&amp; . "$NVM_DIR/nvm.sh"  # This loads nvm' &gt;&gt; "$PROFILE" &amp;&amp; \
      echo '[ -s "$NVM_DIR/bash_completion" ] &amp;&amp; . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' &gt;&gt; "$PROFILE" &amp;&amp; \
      . $NVM_DIR/nvm.sh &amp;&amp; \
      nvm install $NODE_VERSION &amp;&amp; \
      apt-get install npm --yes &amp;&amp; \
      rm -rf /usr/lib/openssh/ssh-keysign &amp;&amp; \
      mkdir -p /tmp/nginx &amp;&amp; \
      pip install awscli &amp;&amp; \
      wget https://github.com/kubernetes/kops/releases/download/1.10.0/kops-linux-amd64 &amp;&amp; \
      wget https://storage.googleapis.com/kubernetes-release/release/v1.8.4/bin/linux/amd64/kubectl &amp;&amp; \
      cp kops-linux-amd64 /usr/local/bin/kops &amp;&amp; \
      cp kubectl /usr/local/bin/kubectl &amp;&amp; \
      chmod a+xX /usr/local/bin/kubectl &amp;&amp; \
      chmod a+xX /usr/local/bin/kops &amp;&amp; \
      apt install docker.io -y &amp;&amp; \
      find / -name 'docker' &amp;&amp; \
      usermod -aG docker root &amp;&amp; \
      service docker start &amp;&amp; \
      find / -name 'docker.sock' &amp;&amp; \
      chmod a+xX /run/docker.sock &amp;&amp; \
      chmod 777 /run/docker.sock &amp;&amp; \
      # this doens't work because it exists in var/run as well which doesn't make sense because its not there in the find command. ln -s /run/docker.sock /var/run/docker.sock &amp;&amp; \
      ls -lah /run/ &amp;&amp; \
      ls -lah /var/run/ &amp;&amp; \
      docker run hello-world
  
  RUN npm install --global lerna
  
  EXPOSE 80
  </code></pre>
  
  <p>Tried everything I can think of. Looking for ideas...</p>