LoginSignup
3
3

More than 5 years have passed since last update.

LXCからGUIアプリケーションを起動する

Posted at

 コンテナ内からFirefoxやNautilusなどのGUIアプリケーションを起動させる設定の備忘です。

 まず、デーモンとして実行中のコンテナで、Firefoxをインストールしておきます。その状態でFirefoxを実行してみるとError: no display specified、適当なDISPLAYオプションを指定してもError: cannot open displayと返されて起動しません。

[user@localhost ~]$ sudo lxc-ls --fancy
NAME      STATE    IPV4            IPV6  AUTOSTART  
--------------------------------------------------
ubuntu01  RUNNING  192.168.122.85  -     NO         

[user@localhost ~]$ sudo lxc-attach -n ubuntu01 --clear-env -- sudo -u ubuntu -i env DISPLAY=$DISPLAY firefox
Error: cannot open display: :0

 そこで、OSの/tmp/.X11-unixをコンテナの/tmp/.X11-unixにマウントするように、設定ファイル/var/lib/lxc/ubuntu01/configに次の行を追記して、コンテナを再起動します。

lxc.mount.entry=/tmp/.X11-unix tmp/.X11-unix none ro,bind,create=dir 0 0

再度、firefoxのコマンドを実行を試してみると、OS(Fedora)からUbuntuのFirefoxを起動することができました。

[user@localhost ~]$ sudo lxc-attach -n ubuntu01 -- sudo -u ubuntu -i env DISPLAY=$DISPLAY firefox

Screenshot from 2015-08-14 17:28:47.png

3
3
0

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
3
3