ubuntu xrdp

main
root 2 years ago
parent c24bc6007c
commit 537e144da3

@ -0,0 +1,44 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# 更新软件包列表并安装所需软件包,包括 Chromium 浏览器
RUN apt-get update && apt-get install -y \
xfce4 \
xfce4-goodies \
xrdp \
sudo \
wget \
ssh \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 下载并安装 Chromium 浏览器的 Debian 包
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& apt-get update \
&& apt-get install -y ./google-chrome-stable_current_amd64.deb \
&& apt-get -f install -y \
&& rm google-chrome-stable_current_amd64.deb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 移除不需要的电源管理器
RUN apt-get remove -y xfce4-power-manager
# 设置默认终端模拟器
RUN update-alternatives --set x-terminal-emulator /usr/bin/xfce4-terminal.wrapper
# 修改 xrdp 配置文件以支持更高的颜色深度
RUN cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak \
&& sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini \
&& sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini \
&& sed -i '/X11/s/^/#/' /etc/xrdp/startwm.sh \
&& echo "startxfce4" >> /etc/xrdp/startwm.sh
# 复制启动脚本并设置可执行权限
COPY start.sh /start.sh
RUN chmod +x /start.sh
# 设置容器启动时运行的命令
CMD ["/start.sh"]

@ -0,0 +1,20 @@
services:
ubuntu-xfce-xrdp:
build: .
image: ubuntu-xfce-xrdp:latest
container_name: ubuntu-xfce-xrdp-3386
ports:
- "3386:3389"
- "11022:22"
environment:
- USERNAME=wcl
- PASSWORD=123
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [gpu]
shm_size: 1g
restart: unless-stopped

@ -0,0 +1,41 @@
#!/bin/bash
# Function to create user
create_user() {
# Check if USERNAME and PASSWORD are set
if [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
echo "USERNAME and PASSWORD environment variables must be set"
exit 1
fi
# Check if user already exists
if id "$USERNAME" &>/dev/null; then
echo "User $USERNAME already exists"
else
# Create user with specified username and password
echo "Creating user: $USERNAME"
useradd -m -s /bin/bash "$USERNAME"
echo "$USERNAME:$PASSWORD" | chpasswd
usermod -aG sudo "$USERNAME"
fi
}
# Function to configure XRDP
configure_xrdp() {
# Start XRDP service
service xrdp start
}
# Function to configure SSH
configure_ssh() {
# Start SSH service
service ssh start
}
# Main script execution
create_user
configure_xrdp
configure_ssh
# Keep the container running
tail -f /dev/null
Loading…
Cancel
Save