基于Arch Linux的远程桌面的Dockerfile设置

mwg9r5ms  于 2023-10-16  发布在  Docker
关注(0)|答案(1)|浏览(188)

我正在努力使以下所需的设置工作:

  • 基于Arch的远程桌面系统(轻量级)
  • 使用RDP,所以我几乎可以从任何Windows机器登录
  • 任何窗口管理器(在这个阶段,我真的不关心任何更多,只要它工作)。xfce 4是我研究得最多的,但实际上,这并不重要。
  • Dockerfile(或YAML/docker-compose)

我失败的次数多得数不清。使用谷歌搜索,bing.chat和chatGPT都无济于事。到目前为止,我最好的结果是一个运行(“docker run -it...”)的系统,允许指定用户通过xrdp登录-但无法加载桌面环境。(这包括首先计算热安装xrdp。
下面是:

# Use the official Arch Linux base image
FROM archlinux:latest

# Update the package repository and install necessary packages
RUN pacman -Syu --noconfirm && pacman -S --noconfirm \
    xorg-server \
    xorg-xinit \
    xterm \
    sed \
    sudo

# Get Requirements for building xrdp
RUN pacman -S --noconfirm git base-devel nasm check fuse libfdk-aac ffmpeg imlib2

# Now make temp user to install - root won't be allowed to 
RUN useradd -m -p $(echo "installnow" | openssl passwd -1 -stdin) installer

# Switch to installer and change into installers home directory
USER installer
WORKDIR /home/installer

# Get yay change into yay dir and make package
RUN git clone https://aur.archlinux.org/xrdp.git
WORKDIR xrdp
RUN makepkg 

# Switch back to root for installation
USER root
WORKDIR /home/installer/xrdp

# have to install built package using pacman - because installation will fail without privileges (duh)
RUN pacman -U --noconfirm *.tar.zst

# Make sure xrdp uses 0.0.0.0 instead of default 127.0.0.1
RUN sed -i 's/127.0.0.1/0.0.0.0/g' /etc/xrdp/xrdp.ini /etc/xrdp/sesman.ini

# Generate a random 16-character alphanumeric password for root
RUN root_password=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16) && \
    echo "root:${root_password}" | chpasswd

# Add a dedicated user and set a password
RUN useradd -m rduser
RUN echo "rduser:secret12345" | chpasswd
RUN usermod -aG wheel rduser

# Create an Xinitrc file for starting the Xorg session
RUN echo "exec startxfce4" > /home/rduser/.xinitrc

# Set permissions for the rduser user
RUN chown rduser:rduser /home/rduser/.xinitrc

# Expose the RDP port (3389)
EXPOSE 3389

# Start xRDP and Xorg when the container runs
CMD ["xrdp", "-n"]

有谁知道如何让它工作吗?
我假设我的麻烦应该或多或少很容易用这个Dockerfile重现,但以防万一。主机系统是strato VPS:

Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04                                                           
Codename:       jammy

5.15.0-83-generic x86_64

最好的,乔

sqserrrh

sqserrrh1#

找到了使用arch的替代方法:Debian Slim在当前版本中。
下面的Dockerfile生成一个工作系统:

# Use the official Debian "bookworm-slim" base image
FROM debian:bookworm-slim

# Set environment variables to avoid interactive prompts during installation
ENV DEBIAN_FRONTEND=noninteractive

# Generate a random 16-character alphanumeric password for root
RUN echo root:$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16) | chpasswd

# Update the package repository and install necessary packages
RUN apt-get update && apt-get install -y \
    xrdp \
    mate-desktop-environment-core \
    falkon

# Add a dedicated user and set a password
RUN useradd -m user
RUN echo "user:userpassword" | chpasswd
RUN usermod -aG sudo user

# Configure xRDP to use MATE as the default session
RUN echo mate-session > /home/user/.xsession

# Set up permissions for the user
RUN chown user:user -R /home/user

# Expose the RDP port (3389)
EXPOSE 3389

# Start xRDP when the container runs
CMD service xrdp start && /bin/bash

相关问题