参考链接
https://github.com/fcwu/docker-ubuntu-vnc-desktop.git
docker pull dorowu/ubuntu-desktop-lxde-vnc
2.直接使用,在浏览器打开,这里设置的端口是6080,在服务器执行这个命令运行之后
docker run --name vnc_test -p 6080:80 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
在浏览器输入服务器ip:6080,比如我的就是
192.168.8.2:6080
3.使用vnc连接
VNC下载地址:
链接:https://pan.baidu.com/s/1YxUn6lOAe-FSzc-NclJk0A?pwd=nhcp
提取码: nhcp 复制这段内容后打开百度网盘手机App,操作更方便哦
用以下命令在服务器创建容器的话就可以通过5900端口从VNC连接docker页面
docker run --name vnc_test -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
创建容器时,建议使用
docker run -d --name vnc_test -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
这样容器在后端运行,可以通过 ocker ps -a== 查看容器运行情况,同时可以通过 docker stop docker_name 来停止,docker start docker_name 重新再后台开启
后面的-v是共享内存,前面的-v是映射文件夹
docker run -d --name vnc_test -v ./docker_data:/home/code -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc
里面的terminal和MobXterm一样需要shift insert插入
这一步的目的是编译一个有cuda支持的ubuntu20.04的有vnc的镜像
1.拉取镜像
git clone --recursive https://github.com/fcwu/docker-ubuntu-vnc-desktop
or, if you have already cloned it, get submodules contents :
git submodule init; git submodule update
在文件夹下运行(每次重新编译都要make clean)
make clean
# FLAVOR=lxqt ARCH=amd64 IMAGE=ubuntu:18.04 make build
FLAVOR=lxde ARCH=amd64 make build
启动镜像(注意镜像名称)
docker run -d --name vnc_test --gpus all -v ./docker_data:/home/code -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc:cuda20.04
https://hub.docker.com/r/nvidia/cuda/tags
如何在docker中安装 vnc桌面版ubuntu 20.04(详细版)
sudo apt update
sudo apt upgrade
安装nano
sudo apt-get install nano
nano /etc/apt/sources.list
把原本内容进行更换
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt update
sudo apt upgrade
这里大概率出现warning,参考报错解决1
创建install.sh,写入
apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
curl \
vim \
locales \
htop \
ca-certificates \
libjpeg-dev \
libpng-dev \
libglfw3-dev \
libglm-dev \
libx11-dev \
libomp-dev \
libegl1-mesa-dev \
pkg-config \
wget \
zip \
sudo \
net-tools \
cmake \
vim \
locales \
wget \
git \
nano \
screen \
gcc \
python3-dev \
bzip2 \
libx11-6 \
libssl-dev \
libffi-dev \
parallel \
tmux \
g++ \
unzip &&\
sudo rm -rf /var/lib/apt/lists/*
执行
bash install.sh
sudo useradd ql -m
usermod -a -G sudo ql
默认是root用户,可以选择切换到user用户下
su ql
bash
可以通过在root下运行
sudo passwd
# 为ql设置密码
sudo passwd ql
设置root密码,那样就可以实现用户之间的切换
curl -Lso ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-py37_4.11.0-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p ~/miniconda \
&& rm ~/miniconda.sh
export PATH=$HOME/ql/miniconda/bin:$PATH
export CONDA_AUTO_UPDATE_CONDA=false
写入环境
nano ~/.bashrc
加上
export PATH=/home/ql/miniconda/bin:$PATH
export PATH=/usr/local/cuda/bin:$PATH
编译
source ~/.bashrc
启动conda环境
conda init
source ~/.bashrc
“f8933fe9402c ”这个是待打包的容器的id,这个是打包的镜像名称
docker commit f8933fe9402c ubuntu_vnc:cuda20.04
启动
docker run -d --name vnc_cuda --gpus all -v ./docker_data:/home/code -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm ubuntu_vnc:cuda20.04
用docker创建ubuntu VNC桌面
1.创建容器
docker run -itd --privileged -v ./docker_data:/home/masteruser/code --gpus all --name vnc_try -p 29:22 -p 3289:3389 -v /dev/shm:/dev/shm vot_dk
2.启动容器
docker exec -it vnc_try /bin/bash
3.换源
nano /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
sudo apt update
sudo apt upgrade
4 安装xfce4
sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils
5.安装vnc4server
# sudo apt install vnc4server # 测试失败
sudo apt install tightvncserver
6.配置VNC
打开vncserver,设置密码
sudo vncserver
关闭vncserver
sudo vncserver -kill :1
sudo nano /root/.vnc/xstartup
添加以下内容
startxfce4 &
xfce4-session &
mate-session &
startkde &
gnome-panel &
gnome-settings-daemon &
metacity &
gnome-terminal &
nautilus &
gnome-session &
sudo vncserver -depth 24 -geometry 1280x800 :0
7.设置xrdp
sudo apt install xrdp
sudo nano /etc/xrdp/xrdp.ini
[Xvnc]
name=Xvnc
lib=libvnc.so
username=root
password=123456
ip=127.0.0.1
port=5900
运行xrdp 服务
service xrdp start
1.【报错解决方案】W: GPG error: http://dl.google.com/linux/chrome/deb stable InRelease