├── sudo.png ├── noVNC.png ├── desktop.png ├── supervisor.conf ├── xsession ├── LICENSE ├── startup.sh ├── Dockerfile └── README.md /sudo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenjr0719/Docker-Ubuntu-Unity-noVNC/HEAD/sudo.png -------------------------------------------------------------------------------- /noVNC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenjr0719/Docker-Ubuntu-Unity-noVNC/HEAD/noVNC.png -------------------------------------------------------------------------------- /desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenjr0719/Docker-Ubuntu-Unity-noVNC/HEAD/desktop.png -------------------------------------------------------------------------------- /supervisor.conf: -------------------------------------------------------------------------------- 1 | [program:vncserver] 2 | command=vncserver -geometry 1600x900 :1 3 | user=ubuntu 4 | 5 | [program:noVNC] 6 | command=/home/ubuntu/noVNC/utils/launch.sh --vnc localhost:5901 7 | user=ubuntu 8 | stdout_logfile=/var/log/novnc.log 9 | redirect_stderr=true 10 | -------------------------------------------------------------------------------- /xsession: -------------------------------------------------------------------------------- 1 | /usr/lib/gnome-session/gnome-session-binary --session=ubuntu & 2 | /usr/lib/x86_64-linux-gnu/unity/unity-panel-service & 3 | /usr/lib/unity-settings-daemon/unity-settings-daemon & 4 | 5 | 6 | for indicator in /usr/lib/x86_64-linux-gnu/indicator-*; do 7 | basename=`basename ${indicator}` 8 | dirname=`dirname ${indicator}` 9 | service=${dirname}/${basename}/${basename}-service 10 | ${service} & 11 | done 12 | 13 | unity 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Jacob 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ ! -f $HOME/.vnc/passwd ] ; then 4 | 5 | if [ -z "$PASSWORD" ] ; then 6 | PASSWORD=`pwgen -c -n -1 12` 7 | echo -e "PASSWORD = $PASSWORD" > $HOME/password.txt 8 | fi 9 | 10 | echo "$USER:$PASSWORD" | chpasswd 11 | 12 | # Set up vncserver 13 | su $USER -c "mkdir $HOME/.vnc && echo '$PASSWORD' | vncpasswd -f > $HOME/.vnc/passwd && chmod 600 $HOME/.vnc/passwd && touch $HOME/.Xresources" 14 | chown -R $USER:$USER $HOME 15 | 16 | if [ ! -z "$SUDO" ]; then 17 | case "$SUDO" in 18 | [yY]|[yY][eE][sS]) 19 | adduser $USER sudo 20 | esac 21 | fi 22 | 23 | else 24 | 25 | VNC_PID=`find $HOME/.vnc -name '*.pid'` 26 | if [ ! -z "$VNC_PID" ] ; then 27 | vncserver -kill :1 28 | rm -rf /tmp/.X1* 29 | fi 30 | 31 | fi 32 | 33 | if [ ! -z "$NGROK" ] ; then 34 | case "$NGROK" in 35 | [yY]|[yY][eE][sS]) 36 | su ubuntu -c "$HOME/ngrok/ngrok http 6080 --log $HOME/ngrok/ngrok.log --log-format json" & 37 | sleep 5 38 | NGROK_URL=`curl -s http://127.0.0.1:4040/status | grep -P "http://.*?ngrok.io" -oh` 39 | su ubuntu -c "echo -e 'Ngrok URL = $NGROK_URL/vnc.html' > $HOME/ngrok/Ngrok_URL.txt" 40 | esac 41 | fi 42 | 43 | /usr/bin/supervisord -n 44 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | MAINTAINER Jacob 3 | 4 | ENV DEBIAN_FRONTEND noninteractive 5 | ENV USER ubuntu 6 | ENV HOME /home/$USER 7 | 8 | # Create new user for vnc login. 9 | RUN adduser $USER --disabled-password 10 | 11 | # Install Ubuntu Unity. 12 | RUN apt-get update \ 13 | && apt-get install -y --no-install-recommends \ 14 | ubuntu-desktop \ 15 | unity-lens-applications \ 16 | gnome-panel \ 17 | metacity \ 18 | nautilus \ 19 | gedit \ 20 | xterm \ 21 | sudo 22 | 23 | # Install dependency components. 24 | RUN apt-get install -y \ 25 | supervisor \ 26 | net-tools \ 27 | curl \ 28 | git \ 29 | pwgen \ 30 | libtasn1-3-bin \ 31 | libglu1-mesa \ 32 | && apt-get autoclean \ 33 | && apt-get autoremove \ 34 | && rm -rf /var/lib/apt/lists/* 35 | 36 | # Download tigerVNC binaries 37 | ADD https://dl.bintray.com/tigervnc/stable/tigervnc-1.9.0.x86_64.tar.gz $HOME/tigervnc/tigervnc.tar.gz 38 | RUN tar xmzf $HOME/tigervnc/tigervnc.tar.gz -C $HOME/tigervnc/ && rm $HOME/tigervnc/tigervnc.tar.gz 39 | RUN cp -R $HOME/tigervnc/tigervnc-1.9.0.x86_64/* / && rm -rf $HOME/tigervnc/ 40 | 41 | # Clone noVNC. 42 | RUN git clone https://github.com/novnc/noVNC.git $HOME/noVNC 43 | RUN cp $HOME/noVNC/vnc.html $HOME/noVNC/index.html 44 | 45 | # Clone websockify for noVNC 46 | Run git clone https://github.com/kanaka/websockify $HOME/noVNC/utils/websockify 47 | 48 | # Download ngrok. 49 | ADD https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip $HOME/ngrok/ngrok.zip 50 | RUN unzip -o $HOME/ngrok/ngrok.zip -d $HOME/ngrok && rm $HOME/ngrok/ngrok.zip 51 | 52 | # Copy supervisor config 53 | COPY supervisor.conf /etc/supervisor/conf.d/ 54 | 55 | # Set xsession of Unity 56 | COPY xsession $HOME/.xsession 57 | 58 | # Copy startup script 59 | COPY startup.sh $HOME 60 | 61 | EXPOSE 6080 5901 4040 62 | CMD ["/bin/bash", "/home/ubuntu/startup.sh"] 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker-Ubuntu-Unity-noVNC 2 | 3 | Dockfile for Ubuntu with Unity desktop environment and noVNC. 4 | 5 | This **Image/Dockerfile** aims to create a container for **Ubuntu 16.04** with **Unity Desktop** and using **TightVNCServer**, **noVNC**, **Ngrok(Optional)** which allow user use browser to log in into this container. 6 | 7 | 8 | ## How to use? 9 | 10 | You can build this **Dockerfile** yourself: 11 | 12 | ``` 13 | sudo docker build -t "chenjr0719/ubuntu-unity-novnc" . 14 | ``` 15 | 16 | Or, just pull my **image**: 17 | 18 | ``` 19 | sudo docker pull chenjr0719/ubuntu-unity-novnc 20 | ``` 21 | 22 | The default usage of this image is: 23 | 24 | ``` 25 | sudo docker run -itd -p 80:6080 chenjr0719/ubuntu-unity-novnc 26 | ``` 27 | 28 | Wait for a few seconds, then you can access http://localhost/ and see this screen: 29 | 30 | ![noVNC](noVNC.png "vnc.html") 31 | 32 | 33 | ### Password 34 | 35 | In default, the **password** will create randomly, to find the password, please using the following command: 36 | 37 | ``` 38 | sudo docker exec $CONTAINER_ID cat /home/ubuntu/password.txt 39 | ``` 40 | 41 | And you can use this password to log in into this container. 42 | 43 | After log in, you can see this screen: 44 | 45 | ![Unity desktop](desktop.png "Unity desktop") 46 | 47 | 48 | ## Arguments 49 | 50 | This image contains 3 input argument: 51 | 52 | 1. Password 53 | 54 | You can set your own user password as you like: 55 | ``` 56 | sudo docker run -itd -p 80:6080 -e PASSWORD=$YOUR_PASSWORD chenjr0719/ubuntu-unity-novnc 57 | ``` 58 | Now, you can user your own password to log in. 59 | 60 | 2. Sudo 61 | 62 | In default, the user **ubuntu** will not be the sudoer, but if you need, you can use this command: 63 | ``` 64 | sudo docker run -itd -p 80:6080 -e SUDO=yes chenjr0719/ubuntu-unity-novnc 65 | ``` 66 | 67 | This command will grant the **sudo** to user **ubuntu**. 68 | 69 | And use **SUDO=YES**, **SUDO=Yes**, **SUDO=Y**, **SUDO=y** are also supported. 70 | 71 | To check the sudo is work , when you open **xTerm** it should show following message: 72 | ``` 73 | To run a command as administrator (user "root"), use "sudo ". 74 | See "man sudo_root" for details. 75 | ``` 76 | 77 | ![sudo](sudo.png "sudo") 78 | 79 | **Caution!!** allow your user as sudoer may cause security issues, use it carefully. 80 | 81 | 3. Ngrok 82 | 83 | [Ngrok](https://ngrok.com/) can be used to deploy localhost to the internet. 84 | 85 | If you need to use this image across the internet, Ngrok is what you need. 86 | 87 | To enable Ngrok, use following command: 88 | 89 | ``` 90 | sudo docker run -itd -p 80:6080 -e NGROK=yes chenjr0719/ubuntu-unity-novnc 91 | ``` 92 | 93 | And find the link address: 94 | 95 | ``` 96 | sudo docker exec $CONTAINER_ID cat /home/ubuntu/ngrok/Ngrok_URL.txt 97 | ``` 98 | 99 | **NGROK=YES**, **NGROK=Yes**, **NGROK=Y**, **NGROK=y** are also supported. 100 | 101 | **Caution!!** this will leave the container open and may cause security issues, use it carefully. 102 | 103 | 104 | ## Screen size 105 | 106 | The default setting of screen siz is 1600x900. 107 | 108 | You can change screen by using following command, this will change screen size to 1024x768: 109 | 110 | ``` 111 | sudo docker exec $CONTAINER_ID sed -i "s|-geometry 1600x900|-geometry 1024x768|g" /etc/supervisor/conf.d/supervisor.conf 112 | sudo docker restart $CONTAINER_ID 113 | ``` 114 | 115 | 116 | ## Issues 117 | 118 | Can't work properly with gnome-terminal, use XTerm in place of it. 119 | 120 | Some components of Unity may not work properly with vncserver. 121 | 122 | This is not a full virtual machine of ubuntu, hence please keep in mind that not everything will work inside of it. 123 | --------------------------------------------------------------------------------