当前位置:   article > 正文

【打工日常】Docker部署一款轻量纯净的网页版Linux系统

网页版linux
  1. 一、项目介绍
  2. 1.项目简述
  3. Docker Webtop是LinuxServer.io团队开发的一个开源项目,它提供了一个基于浏览器的全功能桌面环境,可以直接在Docker容器中运行。通过将Web应用和传统桌面应用相结合,Docker Webtop可以使远程工作和协作变得更加高效和便捷。
  4. 2.项目功能
  5. Docker Webtop集成了多个关键组件,包括Xvfb(一个无头的XServer,用于在后台运行图形应用程序,避免实际的显示器需求)、x11docker(负责将图形输出转发到VNC服务器或本地XServer)、WebRTC(支持实时音视频通信,为远程桌面提供流畅的交互体验)以及NoVNC(一个基于Web的VNC客户端,使得用户可以在任何支持HTML5的现代浏览器中访问桌面环境)。此外,Docker Webtop还集成了其他实用工具,如文件管理器、文本编辑器和终端模拟器,以便用户在浏览器内进行日常操作。
  6. 3.项目开源地址
  7. https://github.com/linuxserver/docker-webtop
  8. ----------
  9. 二、项目搭建环境
  10. 1. 项目测试环境
  11. A.项目搭建在腾讯云centos7.6,外网地址为43.138.153.157
  12. 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
  13. B.docker版本为26.01,docker-compose版本为v2.26.1
  14. 注意:本次实践部署环境为个人腾讯云的测试环境,若是生产环境请谨慎部署;对应开启了容器的端口,在linux下和防火墙下需开放对应端口。
  15. 2. 本次项目实施过程
  16. 使用docker下载镜像,创建好项目需要挂载的路径,通过docker-cli或者docker compose启动容器,启动容器后查看容器启动状态,查看容器的运行日志是否正常,以上全部正常执行后体验项目功能。
  17. 3.注意:docker下载镜像有可能遇到比较慢的情况,参考以下解决措施:
  18. A.docker配置换源,进入/etc/docker的路径,如果没有就创建这个目录
  19. cd /etc/docker/
  20. mkdir -p /etc/docker
  21. B.编辑配置文件
  22. vim daemon.json ##可以清空里面的内容:%d 然后复制下面的源进去wq保存
  23. {
  24. "registry-mirrors":[
  25. "https://286u3d9d.mirror.aliyuncs.com"
  26. ]
  27. }
  28. C.registry-mirrors:指定了一个镜像仓库的 URL https://286u3d9d.mirror.aliyuncs.com。 这个配置项用于设置 Docker镜像的镜像仓库地址,使得在拉取和推送 Docker 镜像时能够通过该镜像仓库进行加速。这边提供的是广东广州服务器的镜源,建议个人自己去阿里云建一个个人账号,根据实际所在区获取镜源。
  29. D.重新加载源,重启docker服务
  30. sudo systemctl daemon-reload
  31. sudo systemctl restart docker
  32. ----------
  33. 三、项目搭建前巡检
  34. 1. 检查docker是否正常运行
  35. systemctl status docker
  36. or
  37. service docker status
  38. 注:我个人测试环境是使用systemctl进行管理,若有使用service管理请使用第二条的命令进行查看。
  39. [root@VM-8-12-centos ~]# systemctl status docker
  40. ● docker.service - Docker Application Container Engine
  41. Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
  42. Active: active (running) since Mon 2024-04-22 23:13:57 CST; 4 days ago
  43. Docs: https://docs.docker.com
  44. Main PID: 17092 (dockerd)
  45. Tasks: 158
  46. Memory: 142.3M
  47. CGroup: /system.slice/docker.service
  48. 若显示docker的Active是active (running),即表明docker是正常运行的。
  49. 2.一般我会使用docker-compose去管理,所以预先需要创建好yaml文件,vim docker-compose.yml,格式如下例子:
  50. version: '3.9'
  51. services:
  52. nginx:
  53. image: nginx
  54. logging:
  55. options:
  56. max-size: 1g
  57. restart: always
  58. volumes:
  59. - '/var/run/docker.sock:/tmp/docker.sock:ro'
  60. ports:
  61. - '80:80'
  62. ----------
  63. 四、项目实施过程
  64. 1.根据开源项目,找到对应的镜像进行pull,若遇到很慢的情况,先检查是否网络问题以及是否已经换源。
  65. docker pull lscr.io/linuxserver/webtop:latest
  66. [root@VM-8-12-centos ~]# docker pull lscr.io/linuxserver/webtop:latest
  67. latest: Pulling from lscr.io/linuxserver/webtop
  68. d1669123f281: Pull complete
  69. 2ec73b48ae40: Pull complete
  70. 64ed7897b25d: Pull complete
  71. eefea741bc5a: Pull complete
  72. 28cc9a8a9caf: Pull complete
  73. c6243262b905: Pull complete
  74. 5c2d9fd83087: Pull complete
  75. e3ebcbb7b55e: Pull complete
  76. 4f4fb700ef54: Pull complete
  77. Digest: sha256:39a32a34a4e4ecd6e289d08d649f530441d5fe3c6cdb60bdc0f1fbc9d1f2bd26
  78. Status: Downloaded newer image for lscr.io/linuxserver/webtop:latest
  79. lscr.io/linuxserver/webtop:latest
  80. 2.若已经下载完成显示新的一行,可以输入命令查看是否上一条命令执行成功
  81. echo$?
  82. 若返回0,则成功;返回其他则根据实际情况重新下载或者查找原因。
  83. 3.docker下载完后,可以查看对应的镜像是否下载成功
  84. docker images |grep webtop
  85. 4.下载成功后,编辑docker-compose.yml文件
  86. version: "2"
  87. services:
  88. webtop:
  89. image: lscr.io/linuxserver/webtop:latest
  90. container_name: webtop
  91. security_opt:
  92. - seccomp:unconfined #optional
  93. environment:
  94. - PUID=1000
  95. - PGID=1000
  96. - TZ=Etc/UTC
  97. - SUBFOLDER=/ #optional
  98. - TITLE=Webtop #optional
  99. volumes:
  100. - /container/compose/docker-linux/data:/config
  101. - /var/run/docker.sock:/var/run/docker.sock #optional
  102. ports:
  103. - 4000:3000
  104. - 4001:3001
  105. devices:
  106. - /dev/dri:/dev/dri #optional
  107. shm_size: "1gb" #optional
  108. restart: unless-stopped
  109. 编辑后输入wq进行保存
  110. 5.为了便捷启动,也可以使用docker-cli启动
  111. docker run -d \
  112. --name=webtop \
  113. --security-opt seccomp=unconfined `#optional` \
  114. -e PUID=1000 \
  115. -e PGID=1000 \
  116. -e TZ=Etc/UTC \
  117. -e SUBFOLDER=/ `#optional` \
  118. -e TITLE=Webtop `#optional` \
  119. -p 4000:3000 \
  120. -p 4001:3001 \
  121. -v /container/compose/docker-linux/data:/config \
  122. -v /var/run/docker.sock:/var/run/docker.sock `#optional` \
  123. --device /dev/dri:/dev/dri `#optional` \
  124. --shm-size="1gb" `#optional` \
  125. --restart unless-stopped \
  126. lscr.io/linuxserver/webtop:latest
  127. 6.启动docker-compose
  128. docker compose up -d
  129. 7.启动容器后,查看容器的状态是否正常
  130. docker ps|grep webtop
  131. root@WellDone:/container/compose/docker-linux# docker ps|grep webtop
  132. 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
  133. 8.启动容器后,查看容器的日志是否正常
  134. docker logs -f webtop
  135. root@WellDone:/container/compose/docker-linux# docker logs -f webtop
  136. [migrations] started
  137. [migrations] no migrations found
  138. ───────────────────────────────────────
  139. ██╗ ███████╗██╗ ██████╗
  140. ██║ ██╔════╝██║██╔═══██╗
  141. ██║ ███████╗██║██║ ██║
  142. ██║ ╚════██║██║██║ ██║
  143. ███████╗███████║██║╚██████╔╝
  144. ╚══════╝╚══════╝╚═╝ ╚═════╝
  145. Brought to you by linuxserver.io
  146. ───────────────────────────────────────
  147. To support LSIO projects visit:
  148. https://www.linuxserver.io/donate/
  149. ───────────────────────────────────────
  150. GID/UID
  151. ───────────────────────────────────────
  152. User UID: 1000
  153. User GID: 1000
  154. ───────────────────────────────────────
  155. **** creating video group videoyirw with id 110 ****
  156. **** adding /dev/dri/renderD128 to video group videoyirw with id 110 ****
  157. **** creating video group videopskx with id 44 ****
  158. **** adding /dev/dri/card0 to video group videopskx with id 44 ****
  159. [custom-init] No custom files found, skipping...
  160. _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
  161. Xvnc KasmVNC 1.2.0 - built May 4 2024 18:54:50
  162. Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
  163. See http://kasmweb.com for information on KasmVNC.
  164. Underlying X server release 12014000, The X.Org Foundation
  165. 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)
  166. [ls.io-init] done.
  167. The XKEYBOARD keymap compiler (xkbcomp) reports:
  168. > Warning: Could not resolve keysym XF86CameraAccessEnable
  169. > Warning: Could not resolve keysym XF86CameraAccessDisable
  170. > Warning: Could not resolve keysym XF86CameraAccessToggle
  171. > Warning: Could not resolve keysym XF86NextElement
  172. > Warning: Could not resolve keysym XF86PreviousElement
  173. > Warning: Could not resolve keysym XF86AutopilotEngageToggle
  174. > Warning: Could not resolve keysym XF86MarkWaypoint
  175. > Warning: Could not resolve keysym XF86Sos
  176. > Warning: Could not resolve keysym XF86NavChart
  177. > Warning: Could not resolve keysym XF86FishingChart
  178. > Warning: Could not resolve keysym XF86SingleRangeRadar
  179. > Warning: Could not resolve keysym XF86DualRangeRadar
  180. > Warning: Could not resolve keysym XF86RadarOverlay
  181. > Warning: Could not resolve keysym XF86TraditionalSonar
  182. > Warning: Could not resolve keysym XF86ClearvuSonar
  183. > Warning: Could not resolve keysym XF86SidevuSonar
  184. > Warning: Could not resolve keysym XF86NavInfo
  185. Errors from xkbcomp are not fatal to the X server
  186. 2024-05-16 08:14:18,058 [INFO] websocket 0: got client connection from 127.0.0.1
  187. 2024-05-16 08:14:18,066 [PRIO] Connections: accepted: @172.20.0.1_1715847258.58490::websocket
  188. ----------
  189. 五、项目体验
  190. 注:云服务器记得放开防火墙!
  191. 访问地址https://43.138.153.157:4000/,欢迎点击玩一下!
  192. 更多好玩有趣有用的内容,请关注微信公众号:零氪的云原生

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/943553
推荐阅读
相关标签
  

闽ICP备14008679号