title: Running X server using Docker
body: <p>I've been trying to get the following to work without success:</p>
  <p><strong>Dockerfile</strong></p>
  <pre><code>FROM ubuntu:latest
  
  #To install without any interactive dialogue
  ENV DEBIAN_FRONTEND=noninteractive
  
  RUN apt-get update
  # Installing Nautilus File Manager
  RUN apt-get install nautilus -y
  
  CMD [&quot;nautilus&quot;]
  </code></pre>
  <p>Then running with:</p>
  <pre><code>sudo docker build -t nautilus-ubuntu .
  
  sudo docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix nautilus-ubuntu
  </code></pre>
  <p>The error that I am getting is:</p>
  <pre><code>Unable to init server: Could not connect: Connection refused
  </code></pre>
  <p>This seems to have been asked heavily before but I've been trying for an hour all I could come across and there's nothing other than xhost + (which is insecure and I don't want to use) that can make this work.</p>
  <p>One thing to note is that I am trying to get this to work in a way that I can build it and launch the target GUI app immediately, without having to log in to a bash session and do further things.</p>