Info Security Memo
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org

Build Confidence

Focusing on Information Security 

Info Security Notes

Install Ubuntu 18.04 Xfce4 Desktop Docker Using Portainer and Access it From Browser (VNC/noVNC)

1/30/2021

0 Comments

 
Install Ubuntu 18.04 Xfce4 Desktop Docker Using Portainer and Access it From Browser (VNC/noVNC)

 It will be helpful for the testing if you have a Linux Desktop environment in the cloud. But I do not want to install a desktop environment to pollute my Linux installation. If I can get a docker environment and let Linux Desktop running inside, that would be a perfect solution. 

Recently I found one Github project "docker-ubuntu-vnc-desktop" to show how to get your own Ubuntu Desktop in the docker. I decided to use Portainer to manage this docker as I did for other docker image. Here are all my steps to get it working. 


Change System Swap File Size

It is usually same size as your RAM. But if your RAM is less than 1GB, you can make your swap file size double.


wget https://raw.githubusercontent.com/51sec/swap/main/swap.sh && bash swap.sh

Follow the prompt to add or delete your swap file size. You do not need to reboot and it will take into effect right away.


Install Docker and Docker Compose

1  Update Package list and Upgrade Packages for Ubuntu 18.04

Update and Upgrade Ubuntu to latest 

$ sudo apt-get -y update && sudo apt-get -y upgrade

2  Install Docker on Ubuntu

sudo apt install docker.io -y
sudo -i
systemctl start docker
systemctl enable docker
docker version

3  Install Docker Compose on Ubuntu

Here is an example using version 1.19.0. You might want to check current release (current is 1.28.2) to update the command. 

root@ip-172-31-28-5:~# curl -L "https://github.com/docker/compose/releases/download/1.19.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   651  100   651    0     0   7076      0 --:--:-- --:--:-- --:--:--  7076
100 8288k  100 8288k    0     0  4671k      0  0:00:01  0:00:01 --:--:-- 7520k
root@ip-172-31-28-5:~# chmod +x /usr/local/bin/docker-compose

root@ip-172-31-28-5:~# docker-compose version
docker-compose version 1.19.0, build 9e633ef
docker-py version: 2.7.0
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t  3 May 2016
root@ip-172-31-28-5:~#



If it is CentOS, the commands to install Docker are different, but for Docker Compose, they are same:

For CentOS 7 install Docker:

sudo -i
yum -y update
curl -sSL https://get.docker.com/ | sh
systemctl start docker.service
systemctl enable docker.service



Install Portainer

Commands to install latest Portainer Docker. 

docker volume create portainer_data
docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
docker ps

Use your browser to access URL http://<public ip of your linuxserver>:9000
First time, it will ask you to set up admin user's password.



Command to Launch Docker-Ubuntu-VNC-Desktop 

Originally from docker-ubuntu-vnc-desktop, the command to run this docker is :

docker run -p 6080:80 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc

With http basic authentication password for root user:

docker run -p 6080:80 -e HTTP_PASSWORD=mypassword -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc


The container has been set to use host's Shared Memory Directory, /dev/shm.

Another interesting Docker file we can take a look is from imlala/ubuntu-xfce-vnc-novnc:

version: '3.5'

services:
    ubuntu-xfce-vnc:
        container_name: xfce
        image: imlala/ubuntu-xfce-vnc-novnc:latest
        shm_size: "1gb"
        ports:
            - 5900:5900
            - 6080:6080
        environment: 
            - VNC_PASSWD=mypassword
            - GEOMETRY=1280x720
            - DEPTH=24
        volumes: 
            - ./Downloads:/root/Downloads
            - ./Documents:/root/Documents
            - ./Pictures:/root/Pictures
            - ./Videos:/root/Videos
            - ./Music:/root/Music
        restart: unless-stopped




Use Portainer to Launch Docker-Ubuntu-VNC-Desktop 

Create a new container from Portainer Containers page:






Set restart policy to Unless stopped.

Environment variables:
for security, we can add one variable, HTTP-PASSWORD, value is the any password you want to set. HTTP-PASSWORD is for user root. 


Now, using a browser to browse to http://<Public IP>:6080


References

  • fcwu/docker-ubuntu-vnc-desktop









via Blogger https://ift.tt/36uF1P4
January 30, 2021 at 12:05PM Docker
0 Comments



Leave a Reply.

    Categories

    All
    Architecture
    Blog
    Checkpoint
    Cisco
    Cloud
    CyberArk
    F5
    Fortigate
    Guardium
    Juniper
    Linux
    Network
    Others
    Palo Alto
    Qualys
    Raspberry Pi
    Security
    SIEM
    Software
    Vmware
    VPN
    Wireless

    Archives

    March 2024
    February 2024
    January 2024
    December 2023
    November 2023
    October 2023
    September 2023
    August 2023
    July 2023
    June 2023
    May 2023
    April 2023
    March 2023
    February 2023
    January 2023
    December 2022
    November 2022
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    September 2020
    August 2020
    July 2020
    October 2019
    September 2019
    June 2019
    July 2018
    May 2018
    December 2017
    August 2017
    April 2017
    March 2017
    January 2017
    December 2016
    November 2016
    October 2016
    September 2016
    August 2016
    July 2016
    June 2016
    May 2016
    April 2016
    March 2016
    February 2016
    January 2016
    December 2015
    November 2015
    October 2015
    September 2015
    August 2015
    July 2015
    June 2015
    May 2015
    April 2015
    March 2015

    Print Page:

    RSS Feed

    Email Subscribe
Powered by Create your own unique website with customizable templates.
  • Blog
  • Sitemap
    • Categories
  • Contact
  • About
  • Resources
  • Tools
  • 51sec.org