LoginSignup
44
56

More than 5 years have passed since last update.

DockerのUbuntuにデスクトップ環境を作成

Posted at

いろいろ開発等をしているとWindowsに限界を感じ、Linux環境をつくることにしました。とはいっても、LinuxのCLIにとても慣れていないためデスクトップ環境を作ろうと。Oracle VM VirtualBoxに作るかDockerに作るか迷ったのですが、とりあえずDocker上に作りました。そのときの記録です。

記事「Dockerに構築したLinuxにリモートデスクトップで接続する」をおおいに参考にしながら、DockerでUbuntuデスクトップ環境をつくっています。

日本人向けのUbuntuデスクトップ環境のDockerイメージを使った方がより簡単なのですが、ブラウザだと操作性が悪そうなので、リモートデスクトップにしています。

環境

種類 バージョン 内容
OS Windows8 64bit 自宅環境なのでProfessionalでもないです
Oracle VM Virtual Box 5.2.22 Docker Toolboxとしてインストール
Docker(Client) 18.03.0-ce
Docker(Server) 18.09.0 1回アップデートしたからClientより新しい?

構築手順

Windows作業

1. Ubuntu Docker ImageのPullとコンテナ作成

docker pull ubuntu
docker run --name ubuntu-xrdp -it ubuntu bash

Dockerコンテナ

2. パッケージリストの最新化

apt-get update
apt-get upgrade

3. xrdpのインストール

xrdp はRDPプロトコルのフリーかつオープンソースのサーバー。

apt-get install xrdp

「The layout of keyboards varies per country, with some countries having multiple common layouts. Please select the country of origin for the keyboard of this computer.」とキーボードレイアウトを聞かれたので
「54. Japanese」を選択( 55. Japanese (PC-98) ではなし)
「Please select the layout matching the keyboard for this machine.」に対しては
「 1. Japanese」を選択

4. lxdeのインストール

(LXDE (Lightweight X11 Desktop Environment) はオープンソースのデスクトップ環境。

apt-get install lxde

「Please select the geographic area in which you live. Subsequent configuration questions will narrow this down by presenting a list of cities, representing the time zones in which they are located.」と使用場所を聞かれたので以下を選択
「 6. Asia」
「 78. Tokyo」

5. デスクトップセッションの設定

cd ~
echo lxsession -s LXDE -e LXDE > ~/.xsession

6. 日本語化モジュールのインストール(1/2)

ibus-mozcは「Google日本語入力(Google IME)」のオープンソース版。

apt-get install ibus-mozc
apt-get install language-pack-ja-base language-pack-ja

update-locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP:ja
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
export LC_CTYPE=ja_JP.UTF-8
source /etc/default/locale

6. 日本語化モジュールのインストール(2/2)

途中でコマンドプロンプトに対する日本語表示でエラーとなってしまったのでGit Bashを使用。Git Bashで以下のコマンドでbash実行。

winpty docker container exec -it ubuntu-xrdp bash
apt-get install unifont
apt-get install synaptic
apt-get install scim-anthy
apt-get install fcitx-anthy

7. パスワード設定

パスワード設定をして終了。

passwd
exit

Windows作業

8. dockerコンテナをコミットし、ポート転送してコンテナ起動。

docker commit ubuntu-xrdp ubuntu-dt
docker run --name ubuntu-dt -p 13389:3389 -it ubuntu-dt bash

Dockerコンテナ

9. xrdpの起動

/etc/init.d/xrdp stop
/etc/init.d/xrdp start

Windowsからリモートログイン

IPアドレスを確認

Docker Quickstart Terminalを起動してIPアドレスを確認します。
10.DockerIP.JPG

RDP(Remote Desktop)

あとはRDP(Remote Desktop)を起動して先に確認したIPアドレスにポートを付加(8で指定したポート番号)。
20.RDP01.JPG

rootユーザでログイン(7で設定したパスワード)。
20.RDP02.JPG

ログインできました!
20.RDP03.JPG

私のPCが低スペックなこともあり、やはり結構、動作が重いので使うのやら・・・

44
56
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
56