赞
踩
- 一、项目介绍
-
- 1.项目简述
- Docker Webtop是LinuxServer.io团队开发的一个开源项目,它提供了一个基于浏览器的全功能桌面环境,可以直接在Docker容器中运行。通过将Web应用和传统桌面应用相结合,Docker Webtop可以使远程工作和协作变得更加高效和便捷。
-
- 2.项目功能
- Docker Webtop集成了多个关键组件,包括Xvfb(一个无头的XServer,用于在后台运行图形应用程序,避免实际的显示器需求)、x11docker(负责将图形输出转发到VNC服务器或本地XServer)、WebRTC(支持实时音视频通信,为远程桌面提供流畅的交互体验)以及NoVNC(一个基于Web的VNC客户端,使得用户可以在任何支持HTML5的现代浏览器中访问桌面环境)。此外,Docker Webtop还集成了其他实用工具,如文件管理器、文本编辑器和终端模拟器,以便用户在浏览器内进行日常操作。
-
- 3.项目开源地址
- https://github.com/linuxserver/docker-webtop
-
-
- ----------
-
- 二、项目搭建环境
-
- 1. 项目测试环境
-
- A.项目搭建在腾讯云centos7.6,外网地址为43.138.153.157
- Linux VM-8-12-centos 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
-
- B.docker版本为26.01,docker-compose版本为v2.26.1
- 注意:本次实践部署环境为个人腾讯云的测试环境,若是生产环境请谨慎部署;对应开启了容器的端口,在linux下和防火墙下需开放对应端口。
-
- 2. 本次项目实施过程
-
- 使用docker下载镜像,创建好项目需要挂载的路径,通过docker-cli或者docker compose启动容器,启动容器后查看容器启动状态,查看容器的运行日志是否正常,以上全部正常执行后体验项目功能。
-
- 3.注意:docker下载镜像有可能遇到比较慢的情况,参考以下解决措施:
-
- A.docker配置换源,进入/etc/docker的路径,如果没有就创建这个目录
- cd /etc/docker/
- mkdir -p /etc/docker
-
- B.编辑配置文件
- vim daemon.json ##可以清空里面的内容:%d 然后复制下面的源进去wq保存
-
- {
- "registry-mirrors":[
- "https://286u3d9d.mirror.aliyuncs.com"
- ]
- }
-
- C.registry-mirrors:指定了一个镜像仓库的 URL https://286u3d9d.mirror.aliyuncs.com。 这个配置项用于设置 Docker镜像的镜像仓库地址,使得在拉取和推送 Docker 镜像时能够通过该镜像仓库进行加速。这边提供的是广东广州服务器的镜源,建议个人自己去阿里云建一个个人账号,根据实际所在区获取镜源。
-
- D.重新加载源,重启docker服务
- sudo systemctl daemon-reload
- sudo systemctl restart docker
-
- ----------
-
-
- 三、项目搭建前巡检
-
- 1. 检查docker是否正常运行
- systemctl status docker
- or
- service docker status
- 注:我个人测试环境是使用systemctl进行管理,若有使用service管理请使用第二条的命令进行查看。
-
- [root@VM-8-12-centos ~]# systemctl status docker
- ● docker.service - Docker Application Container Engine
- Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
- Active: active (running) since Mon 2024-04-22 23:13:57 CST; 4 days ago
- Docs: https://docs.docker.com
- Main PID: 17092 (dockerd)
- Tasks: 158
- Memory: 142.3M
- CGroup: /system.slice/docker.service
-
- 若显示docker的Active是active (running),即表明docker是正常运行的。
-
- 2.一般我会使用docker-compose去管理,所以预先需要创建好yaml文件,vim docker-compose.yml,格式如下例子:
-
- version: '3.9'
- services:
- nginx:
- image: nginx
- logging:
- options:
- max-size: 1g
- restart: always
- volumes:
- - '/var/run/docker.sock:/tmp/docker.sock:ro'
- ports:
- - '80:80'
-
- ----------
-
-
- 四、项目实施过程
-
- 1.根据开源项目,找到对应的镜像进行pull,若遇到很慢的情况,先检查是否网络问题以及是否已经换源。
- docker pull lscr.io/linuxserver/webtop:latest
-
- [root@VM-8-12-centos ~]# docker pull lscr.io/linuxserver/webtop:latest
- latest: Pulling from lscr.io/linuxserver/webtop
- d1669123f281: Pull complete
- 2ec73b48ae40: Pull complete
- 64ed7897b25d: Pull complete
- eefea741bc5a: Pull complete
- 28cc9a8a9caf: Pull complete
- c6243262b905: Pull complete
- 5c2d9fd83087: Pull complete
- e3ebcbb7b55e: Pull complete
- 4f4fb700ef54: Pull complete
- Digest: sha256:39a32a34a4e4ecd6e289d08d649f530441d5fe3c6cdb60bdc0f1fbc9d1f2bd26
- Status: Downloaded newer image for lscr.io/linuxserver/webtop:latest
- lscr.io/linuxserver/webtop:latest
-
- 2.若已经下载完成显示新的一行,可以输入命令查看是否上一条命令执行成功
- echo$?
- 若返回0,则成功;返回其他则根据实际情况重新下载或者查找原因。
-
- 3.docker下载完后,可以查看对应的镜像是否下载成功
- docker images |grep webtop
-
- 4.下载成功后,编辑docker-compose.yml文件
-
- version: "2"
- services:
- webtop:
- image: lscr.io/linuxserver/webtop:latest
- container_name: webtop
- security_opt:
- - seccomp:unconfined #optional
- environment:
- - PUID=1000
- - PGID=1000
- - TZ=Etc/UTC
- - SUBFOLDER=/ #optional
- - TITLE=Webtop #optional
- volumes:
- - /container/compose/docker-linux/data:/config
- - /var/run/docker.sock:/var/run/docker.sock #optional
- ports:
- - 4000:3000
- - 4001:3001
- devices:
- - /dev/dri:/dev/dri #optional
- shm_size: "1gb" #optional
- restart: unless-stopped
-
- 编辑后输入wq进行保存
-
- 5.为了便捷启动,也可以使用docker-cli启动
-
- docker run -d \
- --name=webtop \
- --security-opt seccomp=unconfined `#optional` \
- -e PUID=1000 \
- -e PGID=1000 \
- -e TZ=Etc/UTC \
- -e SUBFOLDER=/ `#optional` \
- -e TITLE=Webtop `#optional` \
- -p 4000:3000 \
- -p 4001:3001 \
- -v /container/compose/docker-linux/data:/config \
- -v /var/run/docker.sock:/var/run/docker.sock `#optional` \
- --device /dev/dri:/dev/dri `#optional` \
- --shm-size="1gb" `#optional` \
- --restart unless-stopped \
- lscr.io/linuxserver/webtop:latest
-
- 6.启动docker-compose
-
- docker compose up -d
-
- 7.启动容器后,查看容器的状态是否正常
-
- docker ps|grep webtop
-
- root@WellDone:/container/compose/docker-linux# docker ps|grep webtop
- 4ec0f06463f8 lscr.io/linuxserver/webtop:latest "/init" 4 hours ago Up 4 hours 0.0.0.0:4000->3000/tcp, :::4000->3000/tcp, 0.0.0.0:4001->3001/tcp, :::4001->3001/tcp webtop
-
- 8.启动容器后,查看容器的日志是否正常
-
- docker logs -f webtop
-
- root@WellDone:/container/compose/docker-linux# docker logs -f webtop
- [migrations] started
- [migrations] no migrations found
- ───────────────────────────────────────
-
- ██╗ ███████╗██╗ ██████╗
- ██║ ██╔════╝██║██╔═══██╗
- ██║ ███████╗██║██║ ██║
- ██║ ╚════██║██║██║ ██║
- ███████╗███████║██║╚██████╔╝
- ╚══════╝╚══════╝╚═╝ ╚═════╝
-
- Brought to you by linuxserver.io
- ───────────────────────────────────────
-
- To support LSIO projects visit:
- https://www.linuxserver.io/donate/
-
- ───────────────────────────────────────
- GID/UID
- ───────────────────────────────────────
-
- User UID: 1000
- User GID: 1000
- ───────────────────────────────────────
-
- **** creating video group videoyirw with id 110 ****
- **** adding /dev/dri/renderD128 to video group videoyirw with id 110 ****
- **** creating video group videopskx with id 44 ****
- **** adding /dev/dri/card0 to video group videopskx with id 44 ****
- [custom-init] No custom files found, skipping...
- _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
-
- Xvnc KasmVNC 1.2.0 - built May 4 2024 18:54:50
- Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
- See http://kasmweb.com for information on KasmVNC.
- Underlying X server release 12014000, The X.Org Foundation
-
- MESA-LOADER: failed to open vgem: Error loading shared library /usr/lib/xorg/modules/dri/vgem_dri.so: No such file or directory (search paths /usr/lib/xorg/modules/dri, suffix _dri)
- [ls.io-init] done.
- The XKEYBOARD keymap compiler (xkbcomp) reports:
- > Warning: Could not resolve keysym XF86CameraAccessEnable
- > Warning: Could not resolve keysym XF86CameraAccessDisable
- > Warning: Could not resolve keysym XF86CameraAccessToggle
- > Warning: Could not resolve keysym XF86NextElement
- > Warning: Could not resolve keysym XF86PreviousElement
- > Warning: Could not resolve keysym XF86AutopilotEngageToggle
- > Warning: Could not resolve keysym XF86MarkWaypoint
- > Warning: Could not resolve keysym XF86Sos
- > Warning: Could not resolve keysym XF86NavChart
- > Warning: Could not resolve keysym XF86FishingChart
- > Warning: Could not resolve keysym XF86SingleRangeRadar
- > Warning: Could not resolve keysym XF86DualRangeRadar
- > Warning: Could not resolve keysym XF86RadarOverlay
- > Warning: Could not resolve keysym XF86TraditionalSonar
- > Warning: Could not resolve keysym XF86ClearvuSonar
- > Warning: Could not resolve keysym XF86SidevuSonar
- > Warning: Could not resolve keysym XF86NavInfo
- Errors from xkbcomp are not fatal to the X server
- 2024-05-16 08:14:18,058 [INFO] websocket 0: got client connection from 127.0.0.1
- 2024-05-16 08:14:18,066 [PRIO] Connections: accepted: @172.20.0.1_1715847258.58490::websocket
-
- ----------
-
-
- 五、项目体验
-
- 注:云服务器记得放开防火墙!
- 访问地址https://43.138.153.157:4000/,欢迎点击玩一下!
- 更多好玩有趣有用的内容,请关注微信公众号:零氪的云原生
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。