title: How to run a docker login command as a different user?
body: <p>How to run a docker login command as a different user?</p>
  
  <pre><code>sudo -u gitlab-runner docker login xxx
  </code></pre>
  
  <p>error:</p>
  
  <pre><code>Warning: failed to get default registry endpoint from daemon (Got permission denied while trying to connect to the Docker daemon socket at &lt;unix:///var/run/docker.sock&gt;: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.30/info: dial unix /var/run/docker.sock: connect: permission denied). Using system default: https://index.docker.io/v1/
  </code></pre>
  
  <p>i even tried this:</p>
  
  <pre><code>su - gitlab-runner -c docker login xxx
  </code></pre>