title: Docker to run X applications while connected through SSH
body: <p>I have used these instructions for <a href="http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/" rel="nofollow">Running Gui Apps with Docker</a> to create images that allow me to launch GUI based applications.</p>
  
  <p>It all works flawlessly when running Docker on the same machine, but it stops working when running it on a remote host.</p>
  
  <p>Locally, I can run</p>
  
  <pre><code>docker --rm --ti -e DISPLAY -e &lt;X tmp&gt; &lt;image_name&gt; xclock
  </code></pre>
  
  <p>And I can get <code>xclock</code> running on my host machine.</p>
  
  <p>When connecting remotely to a host with <code>XForwarding</code>, I am able to run X applications that show up on my local X Server, as anyone would expect.</p>
  
  <p>However if in the remote host I try to run the above docker command, it fails to connect to the <code>DISPLAY</code> (usually <code>localhost:10.0</code>)</p>
  
  <p>I think the problem is that the <code>XForwarding</code> is setup on the localhost interface of the remote host.
  So the docker host has no way to connect to <code>DISPLAY=localhost:10.0</code> because that localhost means the remote host, unreachable from docker itself.</p>
  
  <p>Can anyone suggest an elegant way to solve this?</p>
  
  <p>Regards
  Alessandro</p>
  
  <p><strong>EDIT1</strong>:
  One possible way I guess is to use <code>socat</code> to forward the remote <code>/tmp/.X11-unix</code> to the local machine. This way I would not need to use port forwarding.
  It also looks like <strong><code>openssh</code> 6.7</strong> will natively support unix socket forwarding.</p>