Debianコンテナにリモートで接続すると、特定のエラーが発生します(xrdpとsesman)

Debianコンテナにリモートで接続すると、特定のエラーが発生します(xrdpとsesman)

イメージを作成しました。ドッカーファイルこれはDebian ブックワームユーザーインターフェースを含むXFCEそしてどこで接続するのか寄稿者: xrdp(リモートデスクトップ)。

この問題を解決しましょう。

私は新しいコンテナそれからこの写真でログインできます。UIにRDPを使用し、また、ログアウトそしてもう一度ログインしてください。私がする時だけ再起動コンテナに再度ログインしようとしています(xrdpページ)これはsesmanエラーになります(奇妙なことにsesmanはそうではありません)。活動/開始)。

しかし、もし私がテイスマン開始すべてが"/usr/sbin/xrdp-sesman"正常に戻ります~まで再起動コンテナ。

これは私の側の論理エラーですか?またはこれはsesmanの既知の問題です。

ドッカーファイル:

#use the debian bookworm image
FROM debian:bookworm

#update all package directories
RUN apt update

#install all needed programs like
#XFCE for UI
#xrdp for connecting via RemoteDesktop
#dbus-x11 for that you can connect to the desktop at all (otherwise the connection w>
#xfce4-goodies for the Xfce4 Desktop Environment (https://packages.debian.org/de/sid>
RUN apt install -y xrdp xfce4 dbus-x11

#install usefull tools like: nano, wget, curl and sudo
RUN apt install -y nano wget curl sudo

#FIX: removed the annoying screen "Plugin "Power Manager Plugin" unexpectedly left t>
RUN apt remove xfce4-power-manager-plugins -y

#clean up
RUN apt clean && apt autoremove -y

#create default user called "user", with password "changeme"
RUN useradd -m -s /bin/bash -p $(openssl passwd -1 changeme) user

#copy files
COPY /data/startScript.sh /

#make the start script runable
RUN chmod +x /startScript.sh

#expose the RDP port
EXPOSE 3389

#start the start script and run the container
CMD ["/startScript.sh"]

起動スクリプト

#!/bin/bash

#start the xrdp session manager
/usr/sbin/xrdp-sesman

#start xrdp overall
/usr/sbin/xrdp -n

ユーザーデータ:

Username => user
Password => changeme

コピーして貼り付けるコマンド:

docker build -t debianxfcerdp .
docker run -d -p 3399:3389 --name test01 debianxfcerdp 

ベストアンサー1

Dockerコンテナのxrdpで発生する問題は、コンテナ内のサービスが起動および管理される方法に関連している可能性があります。コンテナが再起動すると、xrdp-sesmanサービスが自動的にトリガーされず、接続が失敗する可能性があります。これがおそらくsesmanを手動で起動した場合、コンテナが再起動されるまで問題が解決する理由です。

考えられる解決策の1つは、Dockerコンテナのエントリポイントまたは起動スクリプトを再設定することで、コンテナが初期化されたときにデフォルトサービス(xrdp-sesmanなど)が起動されるようにすることです。これを行うには、コンテナ内のプロセスマネージャまたはスクリプトを介して管理する必要があります。

Dockerfileで調整した内容は次のとおりです。

#copy the startup script into the container
COPY startScript.sh /usr/local/bin/startScript.sh

#grant execute permissions to the script
RUN chmod +x /usr/local/bin/startScript.sh

# Set the script as entry point to run on container start
ENTRYPOINT ["/usr/local/bin/startScript.sh"]

また、xrdpサービスを正しく開始するにはstartScript.shを変更する必要があります。

#!/bin/bash

# Function to check and start the sesman service if not running
start_sesman() {
    if ! pgrep -x "xrdp-sesman" > /dev/null; then
        echo "xrdp-sesman not running. Starting sesman..."
        /usr/sbin/xrdp-sesman
    else
        echo "xrdp-sesman is already running."
    fi
}

# Start sesman
start_sesman

# Start xrdp
/usr/sbin/xrdp -n

この調整された設定は、コンテナのエントリポイントとしてstartScript.shを起動します。 xrdp-sesmanが実行中であることを確認し、そうでない場合に起動する機能が含まれています。これにより、コンテナの再起動時に必要なサービスが開始されます。

おすすめ記事