使用docker搭建OpenTrace

介绍

OpenTrace 是使用 .NET 6 和 Eto 框架开发的 NextTrace 的跨平台 GUI 界面,带来您熟悉但更强大的用户体验。

那么怎么用docker跑GUI软件呢?🤔

当然有办法!NoVNC允许你通过Web浏览器连接到远程计算机,而无需安装任何额外的客户端软件。

GitHub地址:Archeb/opentrace: A cross-platform GUI wrapper for NextTrace.(github.com)

Docker Hub地址:liwangsheng/opentrace - Docker Image | Docker Hub

示意图,引自:使用Docker容器,将带UI的程序,直接转为Web应用

预览


占用情况

同理可得

安装

仅提供x64架构的docker镜像

构建镜像

一开始是用一个包含了所需命令集合的简单脚本作为容器的启动命令,虽然能用,但有一点问题,重启就寄了,借鉴了下别人的dockerfile,发现使用Supervisor管理进程更加方便,可以保证程序崩溃后,重新把程序启动起来。

所需文件如下:

app
├── conf.d   (子进程配置文件夹)
│   ├── opentrace.conf
│   ├── websockify.conf
│   ├── x11vnc.conf
│   └── xvfb.conf
├── Dockerfile
└── supervisord.conf    (主配置文件)
# Dockerfile
FROM debian:bookworm-slim
WORKDIR /app
ARG OP=1.3.2.0 \
	NT=1.2.4.2

RUN apt-get update && \
    apt-get install -y supervisor novnc x11vnc xvfb libgtk-3-0 libwebkit2gtk-4.0-37  && \
    wget https://github.com/Archeb/opentrace/releases/download/v$OP/linux-x64.tar.gz && \
    wget https://github.com/nxtrace/NTrace-V1/releases/download/v$NT/nexttrace_linux_amd64 && \
    tar -xzf linux-x64.tar.gz && \
    rm linux-x64.tar.gz && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    chmod  x nexttrace_linux_amd64

ENV DISPLAY=:0.0 \
    DISPLAY_WIDTH=1280 \
    DISPLAY_HEIGHT=720

COPY . .
EXPOSE 8080

CMD ["supervisord", "-c", "/app/supervisord.conf"]


# supervisord.conf    前台运行supervisor
[supervisord]
nodaemon=true

[include]
files = /app/conf.d/*.conf

# xvfb.conf    虚拟屏幕
[program:xvfb]
command=Xvfb :0 -screen 0 "%(ENV_DISPLAY_WIDTH)s"x"%(ENV_DISPLAY_HEIGHT)s"x24 -listen tcp -ac  extension GLX  extension RENDER
autorestart=true

# x11vnc.conf    VNC服务器,需要密码可以加上 -passwd 
[program:x11vnc]
command=x11vnc -forever -shared
autorestart=true

# websockify.conf   WebSocket转换TCP
[program:websockify]
command=websockify --web /usr/share/novnc 8080 localhost:5900
autorestart=true

# opentrace.conf     OP!启动
[program:opentrace]
command=/app/OpenTrace
autorestart=true

在Dockerfile文件同级运行docker build -t opentrace .

启动容器

docker run -itd \
  --name opentrace \
  --restart unless-stopped \
  -p 8080:8080 \
  liwangsheng/opentrace

可以修改分辨率但不建议修改,DISPLAY_WIDTH和DISPLAY_HEIGHT

仅本机使用可将端口修改为127.0.0.1:8080:8080(家里云可以用内网ip)

使用方法

访问IP:端口,点击最后三个都可以连接novnc


修改为中文


保存后点击File-Quit,等待自动启动

如果点不到开始按钮请用键盘方向键、回车

想测ipv6简单的方法就是给容器host网络

报错

家里云用的时候容易闪退,暂时不知道原因也不知道解决方法,vps使用倒是正常

报错如下

Process terminated. A callback was made on a garbage collected delegate of type 'Eto.Gtk!Eto.GtkSharp.Forms.Controls.WebViewHandler FinishScriptExecutionDelegate::Invoke'.
   at Eto.GtkSharp.Forms.ApplicationHandler.Run()
   at Eto.Forms.Application.Run(Eto.Forms.Form)
   at OpenTrace.Program.Main(System.String[])
Aborted (core dumped)

参考文档

[1]Archeb/opentrace: A cross-platform GUI wrapper for NextTrace. Bringing you the familiar traceroute experience. (github.com)

[2]theasp/docker-novnc: noVNC Display Container for Docker (github.com)

[3]使用Docker容器,将带UI的程序,直接转为Web应用-云社区-华为云 (huaweicloud.com)

[4]OpenTrace:一款开源跨平台的图形化路由追踪工具 - MJ的博客

点赞
  1. luofeng说道:

    freecad

    docker run -d \
        --name freecad \
        -p 8055:8080 \
        -v /root/playground/test/:/app/document \
        liwangsheng/freecad
    

发表回复

电子邮件地址不会被公开。必填项已用 * 标注

×
订阅图标按钮