当前位置: 首页 > news >正文

Docker - ZZH Ubuntu Image - Desktop

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