Palmsonntagmorgen

NGSデータを使った解析と、その周辺。

docker-ubuntu-vnc-desktopを使ってDockerイメージ (ssp_drompa) をGUIで動かす

更新間隔があいてしまいすみません。 論文書いたり博論審査したり、色々大変です。

今日はDockerのお話です。 最近以下のようなツイートを見つけました。

(ちなみにこのAtsushi SakaiさんはPythonRoboticsの作者です。)

DockerとSingularityについてはこのブログでもエントリを書いたので参照してください。

【Win】【Mac】【Linux】Dockerのインストール 【2019年7月現在】 - Palmsonntagmorgen

Singularityを使ったDocker環境の利用が楽ちんという話 - Palmsonntagmorgen

自分のシングルセル解析DockerイメージをGUIにできれば面白いのでは?と思い、試してみました。

ssp_drompa (GUI) のビルド

シングルセルDockerはイメージが大きくて構築に時間がかかるため、ここではssp_drompaを使って構築します。

以下がDockerfileの全体です。もともとdebianベースのため、基本的には FROMdebianからdorowu-bionicに変えただけです。 rnakato/ubuntu となっていますが、これはdorowu/ubuntu-desktop-lxde-vncにいくつかのパッケージをプリインストールしたもので、基本的に同じと思ってもらって大丈夫です。

FROM rnakato/ubuntu:dorowu-bionic
LABEL maintainer "Ryuichiro Nakato <rnakato@iam.u-tokyo.ac.jp>"

WORKDIR /home
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    build-essential \
    ca-certificates \
    git \
    libboost-all-dev \
    libgsl-dev \
    libgtk2.0-dev \
    libgtkmm-3.0-dev \
    libz-dev \
    r-base \
    samtools \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*
RUN git clone https://github.com/rnakato/SSP.git \
    && cd SSP \
    && make
RUN git clone https://github.com/rnakato/DROMPA3 \
    && cd DROMPA3 \
    && make
RUN git clone --recursive https://github.com/rnakato/DROMPAplus \
    && cd DROMPAplus \
    && git submodule foreach git pull origin master \
    && make
ADD script script

ENV PATH ${PATH}:/home/SSP/bin:/home/DROMPA3:/home/DROMPAplus/bin:/home/DROMPAplus/submodules/cpdf/Linux-Intel-64bit:/home/DROMPAplus/otherbins:/home/script

CMD ["/bin/bash"]

これを rnakato/ssp_drompa:dorowu-bionic という名前でビルドしました。

ssp_drompa (GUI) の実行

上でビルドしたdockerを起動し、ブラウザからアクセスしてみます。
(ビルドしたものは公開していますので、誰でも以下のコマンドで利用可能です。)

$ docker run --rm -it -p 6079:80 rnakato/ssp_drompa:dorowu-bionic

実行環境によると思いますが、上のコマンドを実行すると以下のようなログが続いてどわーっと表示されるかと思います。

2020-03-02 00:13:46,603 CRIT Supervisor running as root (no user in config file)
2020-03-02 00:13:46,603 WARN Included extra file "/etc/supervisor/conf.d/supervisord.conf" during parsing
2020-03-02 00:13:46,617 INFO RPC interface 'supervisor' initialized
2020-03-02 00:13:46,617 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2020-03-02 00:13:46,617 INFO supervisord started with pid 11
2020-03-02 00:13:47,619 INFO spawned: 'nginx' with pid 14
2020-03-02 00:13:47,629 INFO spawned: 'web' with pid 15
2020-03-02 00:13:47,630 INFO spawned: 'novnc' with pid 16
2020-03-02 00:13:47,631 INFO spawned: 'wm' with pid 17
2020-03-02 00:13:47,632 INFO spawned: 'pcmanfm' with pid 18
2020-03-02 00:13:47,634 INFO spawned: 'lxpanel' with pid 19
2020-03-02 00:13:47,637 INFO spawned: 'xvfb' with pid 20
2020-03-02 00:13:47,646 INFO spawned: 'x11vnc' with pid 21
2020-03-02 00:13:47,902 INFO  Listening on http://localhost:6079 (run.py:87)
2020-03-02 00:13:48,715 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,715 INFO success: web entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,715 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,716 INFO success: wm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,716 INFO success: pcmanfm entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,716 INFO success: lxpanel entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,717 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2020-03-02 00:13:48,717 INFO success: x11vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
127.0.0.1 - - [2020-03-02 00:14:16] "GET /api/health HTTP/1.1" 200 122 0.162835
127.0.0.1 - - [2020-03-02 00:14:46] "GET /api/health HTTP/1.1" 200 122 0.143152

途中に 2020-03-02 00:13:47,902 INFO Listening on http://localhost:6079 (run.py:87) というURLが表示されています。このURL (http://localhost:6079) をブラウザに貼り付けるとGUIが開けます。
(6079というのがポート番号です。この数字が6080だったり、その他の数字になっている場合は、dockerをrunするコマンドの -p 6079:80 のポート番号を同じ数字に変更して再実行してください。)

f:id:rnakato:20200302092334j:plain
GUI起動画面

ブラウザでLinuxのデスクトップ環境が開けます。これだけでもテンションが上がりますね!

今回はssp_drompaですので、ターミナルを起動してsspとdrompa+が動くか試してみます。 (スタートメニューから LXTerminal を選択するとターミナルが起動します。)

f:id:rnakato:20200302093204j:plain
ターミナル画面

ターミナル上でちゃんと起動しています。

まとめ

DockerイメージをGUIで起動できると、Rの作図やpdfファイル描画などで「Xウィンドウが開かない」という問題も解決するので、Jupyterを起動するのに比べてもかなり直感的で使いやすくなる印象です。 ちゃんと試していませんが、イメージ内で完結する作業であればほぼ問題なく動作するのではないでしょうか。
GUIが必要な作業はこれで、ターミナル上でコマンド的に使いたい場合はSingularity、とするのがよいかもしれませんね。