title: devcontainer, how to make X display work (mount graphics inside docker in visual studio code)
body: <p>Normally I use this trick to make X work inside docker:</p>
  
  <pre><code>docker run --rm -it -v /tmp/.X11-unix:/tmp/.X11-unix -v $HOME/Videos:/videos -e DISPLAY=unix$DISPLAY --name knl kdenlive
  </code></pre>
  
  <p>I tried doing the same on a devcontainer:</p>
  
  <pre><code>{
      "name": "example_dockerized_environment",
      "dockerFile": "Dockerfile",
      "extensions": [
          "ms-vscode.cpptools",
          "twxs.cmake",
          "eamodio.gitlens"
      ],
      "mounts": [ "source=../,target=/home/project", "source=/tmp/.X11-unix, target=/tmp/.X11-unix"],
      "containerEnv": {
          "DISPLAY": "unix:0"
      },
      "runArgs": ["--privileged"]
  }
  </code></pre>
  
  <p>As you can see, I passed <code>unix$DISPLAY</code> and also mounted <code>X11-unix</code></p>
  
  <p>But I get</p>
  
  <pre><code>root@5e6a10efbea6:/workspaces/leuze_lidar_volume/sdk/quanergy_client-master# ./visualizer --host localhost
  ERROR: In /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx, line 1466
  vtkXOpenGLRenderWindow (0x2293740): bad X server connection. DISPLAY=Aborted (core dumped)
  </code></pre>
  
  <p>When I do <code>echo $DISPLAY</code> inside docker I see nothing. I tried doing</p>
  
  <p>export <code>DISPLAY=unix:0</code> then I get</p>
  
  <pre><code>root@5e6a10efbea6:/workspaces/leuze_lidar_volume/sdk/quanergy_client-master# ./visualizer --host localhost
  ERROR: In /build/vtk6-YpT4yb/vtk6-6.2.0+dfsg1/Rendering/OpenGL/vtkXOpenGLRenderWindow.cxx, line 1466
  vtkXOpenGLRenderWindow (0x281dcf0): bad X server connection. DISPLAY=unix:0. Aborting.
  
  
  Aborted (core dumped)
  </code></pre>
  
  <p>I also see no <code>/tmp.x11-unix</code> inside the container:</p>
  
  <pre><code>root@5e6a10efbea6:/tmp# ls -la /tmp 
  total 16
  drwxrwxrwt 1 root root 4096 Mar 18 03:47 .
  drwxr-xr-x 1 root root 4096 Mar 18 03:45 ..
  srwxr-xr-x 1 root root    0 Mar 18 03:42 vscode-git-askpass-c2ca47727522d7940b4cce1d99fcc88d32ccfefc.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:47 vscode-git-ipc-f52b0dbfd870db22481ea656170b7615ea1e6497.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:45 vscode-ipc-032f3099-16ea-4f5d-8561-586571a4aea9.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:32 vscode-ipc-425af2fc-ddb1-4554-b93b-3a5bede4c52d.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:47 vscode-ipc-58739ccc-fb7d-4289-808e-21d31c703d1a.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:42 vscode-ipc-aa7aed50-92e4-4b2b-b17e-d70c1bba595e.sock
  -rw-r--r-- 1 root root 2342 Mar 18 03:46 vscode-remote-containers-6a199ce05d20a43a350860289798f388414d648c.js
  srwxr-xr-x 1 root root    0 Mar 18 03:46 vscode-remote-containers-ipc-6a199ce05d20a43a350860289798f388414d648c.sock
  srwxr-xr-x 1 root root    0 Mar 18 03:46 vscode-ssh-auth-6a199ce05d20a43a350860289798f388414d648c.sock
  drwxr-xr-x 2 root root 4096 Mar 18 03:46 vscode-typescript0
  root@5e6a10efbea6:/tmp# 
  </code></pre>