远程服务器 docker XRDP 桌面访问 记录

embedded/2024/9/23 10:24:06/

需求描述:

  • 我现在在远程连接 一台服务器,由于需要实验环境需要GUI桌面系统,但是又想在 docker 中运行。
  • 因此,我现在首先需要通过 ssh 连接服务器,然后再服务器中连接 docker.

REF:
https://github.com/danielguerra69/ubuntu-xrdp/tree/16.04
https://blog.csdn.net/weixin_45481037/article/details/134684379?spm=1001.2014.3001.5501

docker_xrdp__8">1. 创建 docker xrdp 镜像。

xrdp-docker 只需要基础的Ubuntu镜像就可以,我换成了自己需要的ubuntu-cuda 镜像也是没问题的

FROM ubuntu:16.04      # 默认镜像
-----
FROM nvidia/cudagl:10.1-devel-ubuntu16.04  # 更换的 base img

NOTE:

  • 需要安装 fakeroot, 报错 2, RUN apt-get install -y fakeroot
  • 需要 给权限,报错 3
  • 国内需要更换 github 镜像,一共两个( ubuntu-16.04 )
    • 使用国内镜像 clone : https://blog.csdn.net/qq_41071191/article/details/121367039
    https://github.com/neutrinolabs/xrdp.git
    https://github.com/neutrinolabs/xorgxrdp.git
    ----
    https://gitclone.com/github.com/neutrinolabs/xrdp.git
    https://gitclone.com/github.com/neutrinolabs/xorgxrdp.git
    

编译dockerfile

  • 默认编译
    docker build -t xrdp_img -f habitat_GUI.dockerfile .
    ----
    -t: 编译img 的名称(tag)
    -f: 变成 dockerfile 的文件
    . : 在当前目录下
    
  • 使用 proxy 编译
    • 因为 dockerfile 中 要下载 github 文件,上面的gitclone镜像不好使了。由于 docker build 是自己创建一个container 进行编译,所以,需要配置编译时的网络。
    • docker build -t xrdp_img --network host -f habitat_GUI.dockerfile .
    • 运行上面命令之前,需要现在本地配置好代理环境,同时需要设置好 docker 的代理环境。
      • https://kebingzao.com/2019/02/22/docker-container-proxy/
      • https://simpleapples.com/2019/04/18/building-docker-image-behind-proxy/

2. 创建container 并连接

  • docker run -d --name uxrdp --hostname terminalserver --shm-size 1g -p 13389:3389 -p 2222:22 xrdp_img
    • docker 绑定了两个端口。
      • docker 的 3389 端口和 服务器的13389 端口绑定。 docker 的 3389 端口用于xrdp 连接。
      • docker 的 22 端口和服务器的 2222 端口绑定。 docker 的 22 端口用于 ssh 连接
      • 因为主机的 3389 和 22 端口都是用于自己的xrdp 和 ssh连接,所以我们不能使用这两个端口,需要更换到 13389 端口(随便选择的)。当我们访问主机的13389 端口,相当于访问 docker 的 3389 端口

  • 远程 ssh 连接, 绑定端口(端口映射)

    ssh -L 3389:localhost:13389  xxx@xxxx
    ssh -L 3389:localhost:13389 -p 12222 xxx@xxxx
    
    • 需要将 本地 3389 端口和 服务器的13389 端口绑定,即本地的3389 和 docker 的3389 绑定。
  • 通过windows xrdp 就可以连接了。

    • 默认user 和 密码都是 ubuntu
    • 可以在dockerfile 中修改

在这里插入图片描述

3. 后续使用

  • 可以ssh 映射不同端口,选择不同的图形界面进行访问。
    ssh -L 3389:localhost:3389  xxx@xxxx     # 远程服务器 GUI
    ssh -L 3389:localhost:13389  xxx@xxxx   # 远程 docker GUI
    
    本地 xrdp 连接参数不用更改,非常方便。

各种报错 😖

  1. W: GPG error: https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY A4B469963BF863CC

    解决方法,在 apt update 之前删除 nivida 源

    RUN rm /etc/apt/sources.list.d/cuda.list
    RUN rm /etc/apt/sources.list.d/nvidia-ml.list
    

    https://github.com/NVIDIA/nvidia-container-toolkit/issues/257

  2. dpkg-buildpackage: warning: using a gain-root-command while being root
    dpkg-buildpackage: error: gain-root-commmand 'fakeroot' not found

    build docker 时报错。 在开始, 安装fakeroot.
    RUN apt-get install -y fakeroot


  3. 2024-05-04 10:45:32.877 [error] Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/bin/docker-entrypoint.sh": permission denied: unknown Error: failed to start containers: bc264b4a0d518933f5e7c306d26423282db0e657dcd6c17fab1d76eb519a3644

    可以正常 build image,但是实例化 container 时,报错,提示权限不够。在dockerfile 中增加权限。

    ADD bin /usr/bin        
    RUN chmod +x /usr/bin/docker-entrypoint.sh   # 新增权限
    

http://www.ppmy.cn/embedded/32684.html

相关文章

启动任何类型操作系统:不需要检索 ISO 文件 | 开源日报 No.243

netbootxyz/netboot.xyz Stars: 7.7k License: Apache-2.0 netboot.xyz 是一个方便的平台,可以不需要检索 ISO 文件就能启动任何类型操作系统或实用工具磁盘。它使用 iPXE 提供用户友好的 BIOS 菜单,让您轻松选择所需的操作系统以及特定版本或可引导标志…

prometheus+grafana的安装与部署及优点

一、Prometheus 的优点 1、非常少的外部依赖,安装使用超简单; 2、已经有非常多的系统集成 例如:docker HAProxy Nginx JMX等等; 3、服务自动化发现; 4、直接集成到代码; 5、设计思想是按照分布式、微服…

ZooKeeper以及DolphinScheduler的用法

目录 一、ZooKeeper的介绍 数据模型 ​编辑 操作使用 ①登录客户端 ​编辑 ②可以查看下面节点有哪些 ③创建新的节点,并指定数据 ④查看节点内的数据 ⑤、删除节点及数据 特殊点: 运行机制: 二、DolphinScheduler的介绍 架构&#…

FastApi个人笔记

FastApi笔记 学习FastApi建议直接看官方文档:官方文档 文章目录 FastApi笔记一、环境准备1.1 安装Fast Api 二、第一个Restful API2.1 创建第一个代码框架async作用[(引自CSDN)](https://blog.csdn.net/The_Time_Runner/article/details/105646363): 2.2 运行第一个代码2.3 Swa…

二叉树的迭代遍历 | LeetCode 144. 二叉树的前序遍历、LeetCode 94. 二叉树的中序遍历、LeetCode 145. 二叉树的后序遍历

二叉树的前序遍历(迭代法) 1、题目 题目链接:144. 二叉树的前序遍历 给你二叉树的根节点 root ,返回它节点值的 前序 遍历。 示例 1: 输入:root [1,null,2,3] 输出:[1,2,3]示例 2&#x…

(4)传输层

1.TCP/UDP区别 2.TCP流量控制P60 3.TCP拥塞控制P61 实际曲线尽量接近理想曲线 4.TCP超时重传时间的选择P62 5.TCP可靠传输的实现P63 6.TCP连接管理 建立 释放 7.TCP报文段的首部格式P66

http和https 所有的请求头信息

http 所有的请求头信息 HTTP请求头信息包含了客户端向服务器发送请求时附带的各种细节信息,帮助服务器更好地处理请求。这些头部字段多种多样,用于说明请求的各个方面,如客户端信息、请求的内容类型、缓存策略等。以下是一些常见的HTTP请求头字段,但请注意,这并非所有可能…

Web的介绍

什么是web web:全球广域网 ,也成为万维网,是通过浏览器访问的网站 web访问的流程 浏览器先对前端服务器(前端程序)发送请求 然后前端服务器对浏览器进行响应 浏览器对后端服务器(Java程序)发…