# docker-headless-vnc-container **Repository Path**: iubest/docker-headless-vnc-container ## Basic Information - **Project Name**: docker-headless-vnc-container - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-09-27 - **Last Updated**: 2021-09-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 如何构建VNC工具镜像 此项目来自[Github](https://www.github.com/dewgenenny/docker-headless-vnc-container), [Dockerhub](https://hub.docker.com/r/dewgenenny/docker-headless-vnc-container), 可以构建可视化工具镜像,通过VNC Viewer或网页进行远程访问。 原作者已不再维护,个人觉得很有意思,而且有一定的使用场景,所以我来继续维护。 ## 构建容器 ```shell git clone https://gitee.com/mythink/docker-headless-vnc-container cd docker-headless-vnc-container docker build -t myvnc:18.04 . ``` ## 启动命令 ```shell #参数说明:5901为VNC Viewer端口,6901为网页访问端口,VNC_PW为登录密码,shm-size提供缓存大小 docker run -itd --user 0 -p 5901:5901 -p 6901:6901 -e VNC_PW=111111 --shm-size=256m myvnc:18.04 #指定分辨率(参考生产环境显示器分辨率) docker run -itd --user 0 -p 5901:5901 -p 6901:6901 -e VNC_RESOLUTION=1920x1080 -e VNC_PW=111111 --shm-size=256m myvnc:18.04 #想要快速体验,可以替换镜像为我的个人镜像 #原版(可定制): limitless-docker.pkg.coding.net/easyblog/wind/myvnc:18.04 #Java版: docker run -itd --user 0 -p 5901:5901 -p 6901:6901 -e VNC_PW=111111 --shm-size=256m \ limitless-docker.pkg.coding.net/easyblog/wind/myvnc:java #Java+Python版: docker run -itd --user 0 -p 5901:5901 -p 6901:6901 -e VNC_PW=111111 --shm-size=256m \ limitless-docker.pkg.coding.net/easyblog/wind/myvnc:plus ``` ## 界面预览 首次登录请点击左侧的齿轮,调节清晰度(Quality拉满) ![img](http://iubest.gitee.io/blogimg/novnc/novnc1.png) 谷歌浏览器登录IP:6901, 界面如图所示(plus版) ![img](http://iubest.gitee.io/blogimg/novnc/novnc3.png) ## 镜像构建过程(可定制) ### 1. 更换壁纸 ``` wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/images/win7.jpeg wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/images/win10-dark.jpg wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/images/win10-light.jpg ``` ### 2. 配置输入法(已配置) ### 3. 系统配置 Applicatons-设置-工作区 改为1,Applicatons-设置-窗口管理器,设置为Kokodi ### 4. 安装wps office,下载字体 ```shell #解决linux wps字体缺失 wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/wps_symbol_fonts.zip unzip wps_symbol_fonts.zip -d /usr/share/fonts/wps-office cd /usr/share/fonts/wps-office mkfontscale mkfontdir fc-cache cd - ``` ### 5. 部署JDK11,Maven ```shell #JDK8用于适配老项目 wget https://limitless.coding.net/p/share/d/jdk8/git/raw/master/jdk1.8.0_202.tar.gz tar zxf jdk1.8.0_202.tar.gz -C /usr/local/ #Maven wget https://limitless.coding.net/p/share/d/openjdk11/git/raw/master/apache-maven-3.8.1-bin.tar.gz tar zxf apache-maven-3.8.1-bin.tar.gz -C /usr/local/ #全局环境使用JDK11 wget https://limitless.coding.net/p/share/d/openjdk11/git/raw/master/openjdk-11%2B28_linux-x64_bin.tar.gz #解压 tar -zxf openjdk-11+28_linux-x64_bin.tar.gz mv jdk-11 /usr/local #快速配置 cat >>/etc/profile<<'EOF' export JAVA_HOME=/usr/local/jdk-11 export CLASSPATH=$JAVA_HOME/lib export MVN_HOME=/usr/local/apache-maven-3.8.1 export PATH=$JAVA_HOME/bin:$MVN_HOME/bin:$PATH EOF source /etc/profile #容器内的/etc/profile可能不生效,还需添加到.bashrc cat >>~/.bashrc<<'EOF' export JAVA_HOME=/usr/local/jdk-11 export CLASSPATH=$JAVA_HOME/lib export MVN_HOME=/usr/local/apache-maven-3.8.1 export PATH=$JAVA_HOME/bin:$MVN_HOME/bin:$PATH EOF #部署完java环境,先重启一下容器,再继续... ``` ### 6. 安装JD-GUI ```shell # Java反编译工具 wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/jd-gui-1.6.6.deb dpkg -i jd-gui-1.6.6.deb ``` ### 7. 安装postman ``` https://www.getpostman.com/apps ``` ### 8. 安装Dbeaver,下载驱动 ``` wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/dbeaver-ce_21.1.4_amd64.deb ``` ### 9. 更新pip,安装python依赖(可选) ```shell pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U pip config set global.index-url https://pypi.douban.com/simple #常用python库 pip install wheel pip install requests pip install aiohttp pip install selenium pip install pymysql pip install redis pip install faker pip install elasticsearch pip install openpyxl pip install xlsxwriter pip install pandas pip install Django pip install djangorestframework pip install paramiko pip install apscheduler pip install matplotlib pip install pyecharts pip install autopep8 pip install ibm_db ``` ### 10. 安装vscode,下载插件 ```shell wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/code_1.59.0-1628120042_amd64.deb #vscode root下关联启动,添加启动参数 --no-sandbox vim /usr/share/applications/code.desktop Exec行添加参数--no-sandbox ``` ```json #配置JDK(开发使用JDK8, 全局使用JDK11) { "remote.autoForwardPortsSource": "output", "java.home": "/usr/local/jdk-11", "maven.executable.path": "/usr/local/apache-maven-3.8.1", "java.configuration.runtimes":[ { "name": "JavaSE-1.8", "path": "/usr/local/jdk1.8.0_202", "default": true }, { "name": "JavaSE-11", "path": "/usr/local/jdk-11" } ] } ``` 安装常用插件 ``` JSON Tools+Prettify JSON Decompiler IntelliJ IDEA Keybindings Bookmarks Bracket Pair Colorizer (彩虹括号) Markdown Preview Enhanced Indent-Rainbow Color Highlight(颜色高亮) Material Icon Theme (图标主题) One Dark Pro(界面主题) Extension Pack for Java Python Django ``` ### 11. 浏览器设置 ```shell 火狐安装中文语言 如果是root用户,chrome启动参数添加 --no-sandbox --test-type 谷歌安装jsonview fehelper https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/fehelper.zip 访问 http://jsonview.com/example.json ``` ### 12. 安装WindTerm终端工具(可选) ```shell #https://github.com/kingToolbox/WindTerm/releases/tag/2.1 #桌面快捷方式 vim WindTerm.desktop [Desktop Entry] Name=WindTerm Exec=/home/wind/app/WindTerm_2.1.0/WindTerm %U Icon=utilities-terminal Type=Application ``` ### 13. 安装Electerm终端工具(推荐) ```shell #https://electerm.github.io/electerm/ #wget https://github.com/electerm/electerm/releases/download/v1.16.5/electerm-1.16.5-linux-amd64.deb #加速下载 wget https://share-1300858685.cos.ap-shanghai.myqcloud.com/share/electerm-1.16.5-linux-amd64.deb sudo dpkg -i electerm-1.16.5-linux-amd64.deb #添加启动参数 --no-sandbox #设置语言为中文 #主题配置(黑底绿字) terminal:foreground=#00FF00 #字体推荐 cousine 18 ``` ### 14. 搭建JAVA开发环境 ``` https://www.eclipse.org/downloads/ # 推荐下载IDEA https://www.jetbrains.com/zh-cn/idea/download/#section=linux ``` ### 15. 创建各快捷方式,清理痕迹,清理软件包 ### 16. 重启容器,docker commit 生成新镜像 ==============以下为原仓库内容============== This repository contains a collection of Docker images with headless VNC environments. Each Docker image is installed with the following components: * Desktop environment [**Xfce4**](http://www.xfce.org) or [**IceWM**](http://www.icewm.org/) * VNC-Server (default VNC port `5901`) * [**noVNC**](https://github.com/novnc/noVNC) - HTML5 VNC client (default http port `6901`) * Browsers: * Mozilla Firefox * Chromium ![Docker VNC Desktop access via HTML page](.pics/vnc_container_view.png) ## Build Status `master`: [![Build Status MASTER](https://travis-ci.org/ConSol/docker-headless-vnc-container.svg?branch=master)](https://travis-ci.org/ConSol/docker-headless-vnc-container) `dev`: [![Build Status DEV](https://travis-ci.org/ConSol/docker-headless-vnc-container.svg?branch=dev)](https://travis-ci.org/ConSol/docker-headless-vnc-container) ## Current provided OS & UI sessions: * `consol/centos-xfce-vnc`: __Centos7 with `Xfce4` UI session__ [![](https://images.microbadger.com/badges/version/consol/centos-xfce-vnc.svg)](https://hub.docker.com/r/consol/centos-xfce-vnc/) [![](https://images.microbadger.com/badges/image/consol/centos-xfce-vnc.svg)](http://microbadger.com/images/consol/centos-xfce-vnc) * `consol/ubuntu-xfce-vnc`: __Ubuntu with `Xfce4` UI session__ [![](https://images.microbadger.com/badges/version/consol/ubuntu-xfce-vnc.svg)](https://hub.docker.com/r/consol/ubuntu-xfce-vnc/) [![](https://images.microbadger.com/badges/image/consol/ubuntu-xfce-vnc.svg)](http://microbadger.com/images/consol/ubuntu-xfce-vnc) * `consol/centos-icewm-vnc`: __Centos7 with `IceWM` UI session__ [![](https://images.microbadger.com/badges/version/consol/centos-icewm-vnc.svg)](https://hub.docker.com/r/consol/centos-icewm-vnc/) [![](https://images.microbadger.com/badges/image/consol/centos-icewm-vnc.svg)](http://microbadger.com/images/consol/centos-icewm-vnc) * `consol/ubuntu-icewm-vnc`: __Ubuntu with `IceWM` UI session__ [![](https://images.microbadger.com/badges/version/consol/ubuntu-icewm-vnc.svg)](https://hub.docker.com/r/consol/ubuntu-icewm-vnc/) [![](https://images.microbadger.com/badges/image/consol/ubuntu-icewm-vnc.svg)](http://microbadger.com/images/consol/ubuntu-icewm-vnc) ## OpenShift / Kubernetes It's also possible to run the images in container orchestration platforms like [Kubernetes](https://kubernetes.io) or [OpenShift](https://openshift.io/). For more information how to deploy containers in the cluster, take a look at: * [Kubernetes usage of "headless" VNC Docker images](./kubernetes/README.md) * [OpenShift usage of "headless" VNC Docker images](./openshift/README.md) ## Usage Usage is **similar** for all provided images, e.g. for `consol/centos-xfce-vnc`: - Print out help page: docker run consol/centos-xfce-vnc --help - Run command with mapping to local port `5901` (vnc protocol) and `6901` (vnc web access): docker run -d -p 5901:5901 -p 6901:6901 consol/centos-xfce-vnc - Change the default user and group within a container to your own with adding `--user $(id -u):$(id -g)`: docker run -d -p 5901:5901 -p 6901:6901 --user $(id -u):$(id -g) consol/centos-xfce-vnc - If you want to get into the container use interactive mode `-it` and `bash` docker run -it -p 5901:5901 -p 6901:6901 consol/centos-xfce-vnc bash - Build an image from scratch: docker build -t consol/centos-xfce-vnc centos-xfce-vnc # Connect & Control If the container is started like mentioned above, connect via one of these options: * connect via __VNC viewer `localhost:5901`__, default password: `vncpassword` * connect via __noVNC HTML5 full client__: [`http://localhost:6901/vnc.html`](http://localhost:6901/vnc.html), default password: `vncpassword` * connect via __noVNC HTML5 lite client__: [`http://localhost:6901/?password=vncpassword`](http://localhost:6901/?password=vncpassword) ## Hints ### 1) Extend a Image with your own software Since version `1.1.0` all images run as non-root user per default, so if you want to extend the image and install software, you have to switch back to the `root` user: ```bash ## Custom Dockerfile FROM consol/centos-xfce-vnc ENV REFRESHED_AT 2018-03-18 # Switch to root user to install additional software USER 0 ## Install a gedit RUN yum install -y gedit \ && yum clean all ## switch back to default user USER 1000 ``` ### 2) Change User of running Sakuli Container Per default, since version `1.3.0` all container processes will be executed with user id `1000`. You can change the user id as follows: #### 2.1) Using root (user id `0`) Add the `--user` flag to your docker run command: docker run -it --user 0 -p 6911:6901 consol/centos-xfce-vnc #### 2.2) Using user and group id of host system Add the `--user` flag to your docker run command: docker run -it -p 6911:6901 --user $(id -u):$(id -g) consol/centos-xfce-vnc ### 3) Override VNC environment variables The following VNC environment variables can be overwritten at the `docker run` phase to customize your desktop environment inside the container: * `VNC_COL_DEPTH`, default: `24` * `VNC_RESOLUTION`, default: `1280x1024` * `VNC_PW`, default: `my-pw` #### 3.1) Example: Override the VNC password Simply overwrite the value of the environment variable `VNC_PW`. For example in the docker run command: docker run -it -p 5901:5901 -p 6901:6901 -e VNC_PW=my-pw consol/centos-xfce-vnc #### 3.2) Example: Override the VNC resolution Simply overwrite the value of the environment variable `VNC_RESOLUTION`. For example in the docker run command: docker run -it -p 5901:5901 -p 6901:6901 -e VNC_RESOLUTION=800x600 consol/centos-xfce-vnc ### 4) View only VNC Since version `1.2.0` it's possible to prevent unwanted control via VNC. Therefore you can set the environment variable `VNC_VIEW_ONLY=true`. If set, the startup script will create a random password for the control connection and use the value of `VNC_PW` for view only connection over the VNC connection. docker run -it -p 5901:5901 -p 6901:6901 -e VNC_VIEW_ONLY=true consol/centos-xfce-vnc ### 5) Known Issues #### 5.1) Chromium crashes with high VNC_RESOLUTION ([#53](https://github.com/ConSol/docker-headless-vnc-container/issues/53)) If you open some graphic/work intensive websites in the Docker container (especially with high resolutions e.g. `1920x1080`) it can happen that Chromium crashes without any specific reason. The problem there is the too small `/dev/shm` size in the container. Currently there is no other way, as define this size on startup via `--shm-size` option, see [#53 - Solution](https://github.com/ConSol/docker-headless-vnc-container/issues/53#issuecomment-347265977): docker run --shm-size=256m -it -p 6901:6901 -e VNC_RESOLUTION=1920x1080 consol/centos-xfce-vnc chromium-browser http://map.norsecorp.com/ Thx @raghavkarol for the hint! ## How to release See **[how-to-release.md](./how-to-release.md)** ## Contributors At this point we want to thank all contributors, which helped to move this great project by submitting code, writing documentation, or adapting other tools to play well together with the docker headless container. * [Tobias Schneck](https://github.com/toschneck) * [Robert Bohne](https://github.com/rbo) - IceWM images * [hsiaoyi0504](https://github.com/hsiaoyi0504) - PR [#66](https://github.com/ConSol/docker-headless-vnc-container/pull/66) * [dmhumph](https://github.com/dmhumph) - PR [#44](https://github.com/ConSol/docker-headless-vnc-container/issue/44) * [Simon Hofmann](https://github.com/s1hofmann) ## Changelog The current changelog is provided here: **[changelog.md](./changelog.md)**