# Docker GUI ## 用別人做好的 image 1. 使用做好的 image 2. 本機安裝 VNC * install image ```bash $ sudo docker run -d -p 6080:80 -p 5900:5900 -v /dev/shm:/dev/shm dorowu/ubuntu-desktop-lxde-vnc ``` * download VNC [Download RealVNC® Viewer](https://www.realvnc.com/en/connect/download/viewer/) * connect **Input IP and port: 5900**  **網卡資訊一致**  ## 自己建一個 VNC image * 建目錄跟檔案 ```bash= $ mkdir -p docker_vnc $ cd docker_vnc/ $ vim Dockerfile ``` ```dockerfile= FROM ubuntu:14.04 ENV DEBIAN_FRONTEND noninteractive ENV HOME /root RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list RUN \ apt-get update && \ apt-get install -y build-essential && \ apt-get install -y software-properties-common && \ apt-get install -y byobu curl git htop man unzip vim wget && \ apt-get install -y xorg lxde-core lxterminal tightvncserver && \ rm -rf /var/lib/apt/lists/* EXPOSE 5901 WORKDIR /root CMD ["bash"] ``` * 建立 image ```bash= $ sudo docker build -t ubuntu-vnc:1.0 . # 沒意外會跑一下子 ``` * 執行 ```bash= $ sudo docker run -it --rm -p 5901:5901 -e USER=root ubuntu-vnc:1.0 bash -c "vncserver :1 -geometry 1280x800 -depth 24 && tail -F /root/.vnc/*.log" ``` :::warning 這邊不能加上參數 `-d` !!! ::: * 執行後設定 ```bash= # 會出現下面問題, 完成候用 VNC 連線, 連線時的密碼就是這邊設定的 You will require a password to access your desktops. Password: Verify: Would you like to enter a view-only password (y/n)? n ``` GPT解釋: :::info `vncserver :1 -geometry 1280x800 -depth 24`:這部分啟動了一個 VNC 服務,使用 `:1` 表示顯示器 1,並設定了顯示器的幾何尺寸(`-geometry`)、色深(`-depth`)等參數。這樣,當容器啟動時,VNC 服務將同時啟動。 `tail -F /root/.vnc/*.log`:這部分則是在 VNC 服務啟動後,通過 `tail` 命令實時追蹤 VNC 服務的日誌文件,保持對日誌的監視。 整體來說,這個命令的作用是在容器啟動時啟動一個 VNC 服務(顯示器 1,尺寸 1280x800,色深 24),並且同時實時監視 VNC 服務的日誌。这可能是為了方便在容器運行期間監視 VNC 服務的狀態和日誌。 :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up