Using VNC with Docker


Maybe this thread about running GUI applications in docker might help you out? It should be possible and the top answer shows how it should be done.

Alternatively there is this tutorial which seems to do the same thing, but is explained a little more in depth.

Andrew Shen
Author by

Andrew Shen

Updated on June 04, 2022


  • Andrew Shen
    Andrew Shen 7 months

    this is my first time using VNC and docker. I want to connect to my docker's GUI.

    I have tried to follow a few tutorials online but my VNC viewer cannot connect to the display. I have exposed port 5900 in my dockerfile, and inside docker I have ran Xvbf :1 -screen 0 1600x1200x16 & export DISPLAY=:1 and x11vnc. It seems to work and I get message saying that the desktop is at port 5900. However I still cannot connect to localhost:5900 in my vnc viewer.

    What am I doing wrong, and what can I use to diagnose my problem? Thanks!

    • Paolo
      Paolo over 2 years
      Did you bind the port when launching the container (-p) ?
    • David Maze
      David Maze over 2 years
      Containers don't typically run interactive desktop applications. If you start running a VNC server, and a GNOME login, and a full desktop environment, you're stepping a little outside the "lightweight packaging around a single process" model, and a full VM running a standard desktop OS might be a better match.
    • Andrew Shen
      Andrew Shen over 2 years
      I have used the -p option. As to the other comment, yes I should probably look to a VM, but I did not write the docker image and are afraid of messing up some system dependencies.
    • StayOnTarget
      StayOnTarget over 1 year
      I’m voting to close this question because it has nothing to do with programming