Run Ubuntu Linux in Docker with Desktop Environment and VNC
Run Ubuntu Linux in Docker with Desktop Environment and VNC
Step 1 – Install Docker on your System
|
|
Add your system user to the Docker group to be able to execute Docker commands without *sudo*.
|
|
Verify the installed Docker version.
|
|
Step 2 – Pull the Ubuntu Docker Image
As said earlier, there are several images for Ubuntu that can be pulled. These images are available on the Docker page and can be pulled using Docker as shown.
|
|
Once the desired Ubuntu image has been pulled, check if it is available in the local registry.
|
|
Step 3 – Run the Ubuntu Container with Desktop Environment
Here, we will go through several methods with configuration on how you can run the Ubuntu container to give you an intuitive experience.
Quick Start.
You can simply run the container and access it via port 6080 using the command below.
|
|
In the above command, we have set the container name to *ubuntu_desktop* and a persistent volume at */dev/shm* Remember to replace ubuntu-desktop-lxde-vnc with the appropriate image pulled.
Check if the container is running with the port exposed.
|
|
As seen from the output, we have port 6080 exposed. Allow it through the firewall and proceed to access the Ubuntu Desktop using the URL http://IP_Address:6080/.
Set HTTP Base Authentication
You can also set a password to be used when accessing the HTTP page on port 6080 by adding the HTTP_PASSWORD variable to the above command:
|
|
Now accessing the page, you will be required to provide a password.
Enable VNC Viewer
The VNC viewer is accessed via a separate port 5900 that needs to be exposed in order to access it. The VNC Viewer port can be exposed as below.
|
|
Here, the VNC viewer should be available on port *5900*.
You can as well set a password for the viewer by adding the VNC_PASSWORD variable to the above command:
|
|
Encrypt with SSL.
You can generate SSL certificates for encryption. In this guide, we will generate self-signed certificates as below.
Ensure that OpenSSL is installed on your system before you proceed:
|
|
Now when running the container, you need to specify the SSL_PORT and the path to the generated certificate as below.
|
|
Here, you can access the Ubuntu Desktop using the URL https://IP_address:6081.