ZhangZhihui's Blog  

1. Pull the ubuntu:24.04 image.

 

2. Set shared directory so that I can operate on files in both Windows and the container:

1

 

3. Create the Dockerfile file:

FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

# Install core packages, dev tools, XFCE, and VNC
RUN apt-get update && apt-get install -y \
    sudo \
    curl \
    git \
    locales \
    vim \
    python3 \
    python3-pip \
    && 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'
RUN useradd zzh && usermod -aG sudo zzh

USER zzh
WORKDIR /home/zzh

 

4. Build image:

PS D:\VSCodeWorkspace\ZUBT> docker build --no-cache -t ubuntu-zzh .

 

5. Create the docker-compose.yml file:

services:
  ubuntu-zzh:
    image: ubuntu-zzh
    container_name: ZUBT
    hostname: ZUBT
    tty: true
    stdin_open: true
    volumes:
      - D:/Docker/Volumes/ZUBT/home/zzh:/home/zzh
    command: tail -f /dev/null

 

6. Start a container:

PS D:\VSCodeWorkspace\ZUBT> docker compose up -d
[+] Running 2/2
 ✔ Network zubt_default  Created                                                                                                                                                                   0.0s 
 ✔ Container ZUBT        Started

 

7. Get a shell inside:

PS D:\> docker exec -it ZUBT /bin/bash
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

zzh@ZUBT:~$

 

posted on 2025-09-21 13:27  ZhangZhihuiAAA  阅读(6)  评论(0)    收藏  举报