要在 Singularity 中運行圖形程序需要重新制作一個鏡像,使其包含執行圖形應用程序需要的環境和程序,這裏還是通過 sandbox 的方式來製作一個可以運行圖形程序鏡像。
首先以 root 身份運行命令創建一個 centos 的 sandbox。
$ sudo singularity -d build --sandbox centos/ docker://centos
如果已經下載過 centos.simg 鏡像,也可以通過下面的命令將其轉換爲一個 sandbox。
$ sudo singularity build --sandbox centos/ centos.simg
用 root 用戶以可寫的方式運行容器,並安裝桌面環境
$ sudo singularity shell --writable centos/
Singularity: Invoking an interactive shell within container...
Singularity centos:~> yum groupinstall -y "GNOME Desktop"
退出容器並製作成鏡像文件
$ sudo singularity build centos-gui.simg centos/
測試一下,啓動一個gedit界面看看
singularity exec centos/ gedit