How to open Ubuntu GUI inside a Docker image

Shan Khan picture Shan Khan · Nov 17, 2016 · Viewed 65.3k times · Source

I have downloaded the Ubuntu image inside Docker on Windows.

I can run Ubuntu by:

docker run -it ubuntu

I only see root, but I don't see the Ubuntu GUI. How do I install or configure the GUI for that image and run applications on that GUI like we run in a VM?

Answer

fcwu/docker-ubuntu-vnc-desktop

https://github.com/fcwu/docker-ubuntu-vnc-desktop provides a convenient setup:

docker run --name ubvnc -p 6080:80 -p 5900:5900 dorowu/ubuntu-desktop-lxde-vnc:bionic

Then either:

  • visit: http://127.0.0.1:6080/#/ which runs a noVNC more limited JavaScript VNC client

  • run:

    sudo apt-get install tigervnc-viewer
    xtigervncviewer :5900
    

    Then inside vinagre, you might want to go into full screen mode to be able to see the full desktop

    I also tried vinagre, but it was much laggier when scrolling Firefox on YouTube.

enter image description here

To quit just kill docker on the terminal. And to restart the machine:

docker start ubvnc

and then reconnect with VNC. Then to quit the machine:

docker stop ubvnc

You have to wait a few seconds for the VNC server on the guest to start before you can connect.

Chromium inside the guest won't start from the menu. If you try to launch it from the command line it explains why:

Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

so just run it from the CLI with:

chromium-browser --no-sandbox

Firefox does not care however.

TODO: no audio. --device /dev/snd did not help:

See also:

Tested on Ubuntu 19.04 host, fcwu/docker-ubuntu-vnc-desktop, dorowu/ubuntu-desktop-lxde-vnc image id: 70516b87e92d.