title: Docker cannot connect to X server
body: <p>I have created a docker image for opencv and facial reckognition to simplify the setup process.</p>
  
  <p>But the recognize.py script needs X Server to show the image result. Here is what I have done so far:</p>
  
  <pre><code>sudo docker run -t -d --name opencv opencv:latest
  sudo docker exec -it opencv bash /extract-embeddings.sh
  sudo docker exec -it opencv bash /train-model.sh
  </code></pre>
  
  <p>All is fine so far. The last step is the actual comparison that displays the result in an image.</p>
  
  <pre><code>sudo docker exec -it opencv bash /face-recognition.sh
  </code></pre>
  
  <p>It gives the output:</p>
  
  <pre><code>[INFO] loading face detector...
  [INFO] loading face recognizer...
  No protocol specified
  : cannot connect to X server :0
  </code></pre>
  
  <p>I have tried running the container with the following command:</p>
  
  <pre><code>sudo docker run -t -d --name opencv -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix opencv:latest
  </code></pre>
  
  <p>But it doesn't help.</p>