Docker - ZZH Ubuntu Image - Desktop

news/2025/9/21 14:13:20/文章来源:https://www.cnblogs.com/zhangzhihui/p/19103612

Here’s the final all-in-one Dockerfile for your ubuntu-zzh-vnc container, ready to build and run on Windows. It includes:

  • XFCE desktop (lightweight)

  • zsh + Oh My Zsh with agnoster theme

  • Common dev tools: vim, htop, python3, pip, nodejs, npm

  • VNC server with clipboard sharing

  • Persistent home folder (/home/zzh)

  • Non-root user zzh

  • UTF-8 locale


Final Dockerfile

FROM ubuntu:24.04ENV DEBIAN_FRONTEND=noninteractive# Install base packages, dev tools, XFCE, and VNC
RUN apt-get update && apt-get install -y \sudo \zsh \curl \git \nano \locales \vim \htop \python3 \python3-pip \nodejs \npm \xfce4 xfce4-terminal \thunar \tigervnc-standalone-server \tigervnc-common \&& rm -rf /var/lib/apt/lists/*# Set UTF-8 locale
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8# Create non-root user 'zzh' with zsh shell
RUN useradd -ms /bin/zsh zzh \&& usermod -aG sudo zzhUSER zzh
WORKDIR /home/zzh# Install Oh My Zsh and set theme + aliases
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended \&& sed -i 's/ZSH_THEME=".*"/ZSH_THEME="agnoster"/' ~/.zshrc \&& echo 'alias ll="ls -alF"' >> ~/.zshrc \&& echo 'alias la="ls -A"' >> ~/.zshrc \&& echo 'alias l="ls -CF"' >> ~/.zshrc# Setup VNC password and persistent configuration
RUN mkdir -p /home/zzh/.vnc \&& echo "1234" | vncpasswd -f > /home/zzh/.vnc/passwd \&& chmod 600 /home/zzh/.vnc/passwd# Persistent VNC startup script
RUN echo "#!/bin/bash\nexport USER=zzh\nexport HOME=/home/zzh\nvncserver :1 -geometry 1280x800 -fg -localhost no -SecurityTypes VncAuth\n" \> /home/zzh/startvnc.sh \&& chmod +x /home/zzh/startvnc.sh# Expose VNC port
EXPOSE 5901# Default shell
SHELL ["/bin/zsh", "-c"]# Start VNC as non-root user on container start
CMD ["/home/zzh/startvnc.sh"]

 

🔧 Build & Run

  1. Build the image:

 
docker build -t ubuntu-zzh-vnc .

 

  1. Run the container with persistent home:

docker run -d -p 5901:5901 --name ZUBT \-v D:/Docker/Volumes/ZUBT/home/zzh:/home/zzh \ubuntu-zzh-vnc

 

  1. Connect from Windows using a VNC client (TigerVNC Viewer):

  • Server: localhost:5901

  • Password: 1234

  1. Optional: Exec into container shell anytime:

docker exec -it ZUBT zsh

 

You’ll be logged in as zzh with zsh + Oh My Zsh ready.


Features now:

  • XFCE GUI accessible via VNC

  • Persistent home folder mapped to Windows

  • zsh + Oh My Zsh with theme and aliases

  • Common dev tools installed

  • Clipboard sharing enabled via VNC

  • Non-root user by default

 

Here’s a ready-to-use docker-compose.yml for your ubuntu-zzh-vnc container. This will handle the image build, persistent volume, and port mapping, so you can start everything with one command.


docker-compose.yml

version: "3.9"services:ubuntu-vnc:build:context: .       # folder where your Dockerfile isdockerfile: Dockerfileimage: ubuntu-zzh-vnccontainer_name: ZUBTtty: truestdin_open: trueports:- "5901:5901"    # VNC server portvolumes:- D:/Docker/Volumes/ZUBT/home/zzh:/home/zzh  # persistent home folder

 


🔧 Usage

  1. Make sure your Dockerfile and docker-compose.yml are in the same folder.

  2. Build and start the container:

docker compose up -d --build

 

  1. Connect via VNC (TigerVNC Viewer):

  • Server: localhost:5901

  • Password: 1234

  1. Exec into the container shell if needed:

docker exec -it ZUBT zsh

 

  1. Stop the container:

docker compose down

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/908807.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C#文件操作入门

Unity游戏开发中对于文件操作是一个不可或缺的部分,尤其是需要存取玩家数据、配置信息或进行资源管理时,C#的文件操作成为了开发者的重要工具。下面将详细介绍Unity中如何使用C#进行基础的文件操作。 首先,C#中Syst…

Java课前问题列表-面向对象入门2与类的识别

Java课前问题列表-面向对象入门2与类的识别1.关于static修饰 什么样的方法应该用 static 修饰? 答: 当一个方法满足以下条件时,应该考虑使用 static 修饰:不依赖于特定对象的实例状态:方法的行为不依赖于或修改其…

ES——(一)基本概念 - 指南

ES——(一)基本概念 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco"…

意义感是完全主观的

意义感是完全主观的意义感是完全主观的 意义感是完全主观的,是人自己构建的。 因为我存在,一切才有了意义。告诉你们一个秘密,其实这个世界只有你一个人,你在,世界就在;你没了,世界也就消失了。 优绩主义。 旅居…

python2.7+pandas

python2.7+pandas版本: Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license&q…

SAP集成HTTP接口(x-www-form-urlencoded格式)

SAP集成HTTP接口是一个重要且常见的企业信息系统扩展方式,特别是当我们需要将SAP与外部系统进行数据交换时。在这种场景中,通常使用HTTP协议来实现不同系统间的通信和数据传输。HTTP协议支持多种数据编码格式,其中之…

iText与OpenPDF使用差异及中文处理完全指南 - 实践

iText与OpenPDF使用差异及中文处理完全指南 - 实践pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas"…

【session反序列化】 - 指南

【session反序列化】 - 指南2025-09-21 14:02 tlnshuju 阅读(0) 评论(0) 收藏 举报pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important;…

Fmt库在CentOS 7的应用指南

Fmt库是一个开源项目,提供了一套用于格式化文本的函数。它可以作为一种现代的、类型安全的替代printf和iostreams。由于其简单的API、高效的实现和轻松的集成,它在C++社区中变得越来越流行。 要在CentOS 7上应用Fmt库…

在k8s集群中解决master节点与node通信

检查网络插件:K8s网络插件需要正常工作才能让Pods跨不同节点通信。确保网络插件(如Calico、Flannel、Weave)配置正确,并且正常运行。 检查节点状态:使用 kubectl get nodes查看所有节点状态。所有节点应显示为 Re…

在Go中构建应用级IP防火墙机制

构建应用级IP防火墙机制可以通过在应用层面进行请求过滤来实现。在Go语言中,这通常意味着编写中间件,该中间件会检查进入应用程序的每个请求的IP地址,并决定允许或拒绝该请求。 package mainimport ("fmt"…

PCIe 8.0 v0.3草案公布:SSD硬盘能飙1TB/s速度

PCIe 8.0 v0.3草案公布:SSD硬盘能飙1TB/s速度Posted on 2025-09-21 13:48 lzhdim 阅读(0) 评论(0) 收藏 举报AI时代对高速连接的需求也要提升,PCI-SIG组织今年也加快了新标准的制定,PCIe 7.0标准正式发布没多久…

用 R 语言实现验证码识别

在 R 中,我们可以利用 tesseract 包来实现OCR识别。这个包是 R 对 Tesseract 引擎的封装,使得我们能够直接在 R 脚本中使用 Tesseract 进行图像识别。 更多内容访问ttocr.com或联系1436423940 安装 R 和必要的包 首先…

用 Lua 实现验证码识别

Lua 本身不直接支持图像处理或 OCR,但可以通过调用外部程序,如 tesseract,来实现验证码识别。我们可以通过 Lua 的 os.execute 函数来调用命令行工具 Tesseract 来实现图像识别。 安装 Tesseract 首先,你需要安装 …

完整教程:【RabbitMQ】-----详解RabbitMQ高级特性之消息确认机制

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …

PHP中常见数组操作函数

PHP中的数组操作函数涵盖了多种实用操作,包括数组排序、遍历、修改和检查等。以下是一些PHP中常用的数组操作函数及其使用方法:排序sort(): 对数组进行升序排序。 rsort(): 对数组进行降序排序。 asort(): 对关联数组…

修复Ubuntu系统文件损坏:手动fsck指令

在Ubuntu系统中,当文件系统出现损坏或一致性问题时,fsck(文件系统检查)工具是一个重要的修复手段。这个命令是专为检查和修复文件系统错误而设计,支持多种文件系统类型,包括但不限于ext2/ext3/ext4、Btrfs、XFS等…

Python网络请求库requests使用详述

Python的 requests库是一种广泛使用的HTTP客户端库,它允许你发送HTTP/1.1请求易如反掌。它的设计目标是使HTTP请求对开发者来说尽可能得简单快捷。requests库遵循RFC 7231的HTTP协议标准,并提供了多种功能,比如会话…

数据结构与排序算法:从理论到场景,解锁高效数据处理的核心逻辑 - 指南

pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", …