0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

apptainerをUbuntu24.04にインストールする

Last updated at Posted at 2025-04-27

はじめに

コンテナを実行する環境として,HPC分野ではSingularityがよく用いられています.以前,Singularity入門としていくつか記事を書きましたが,近年SingularityプロジェクトがLinux Foundationに移行したことで名称がApptainerとなって新しくなっています.ただし,コマンド名が新しく変わっただけで基本的な利用方法はsingularityと変わらないようです.

本記事では以前のSingularityの記事の更新として,ApptainerをUbuntu24.04にインストールし使用する方法をまとめたいと思います.

過去に投稿したsingularity関連の記事

インストール

インストールするマシンのOSは Ubuntu 24.04 LTS とします.

基本的なインストール手順はapptainer公式のAdmin Guideを参照しています.

まず必要なリポジトリ等の準備をします.

sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:apptainer/ppa

続いて,apptainerのインストールを行います.

sudo apt update
sudo apt install -y apptainer

以上でAdmin guideにあるインストールは完了ですが,Ubuntu24.04の場合ここでコンテナを起動しようとすると次のようなエラーメッセージが表示されうまく動作しませんでした.なお,コンテナの起動はsudoをつけずに一般ユーザ権限で実施します.

ERROR  : Could not write info to setgroups: Permission denied
ERROR  : Error while waiting event for user namespace mappings: no event received

そこで,apptainerのGitHubを確認したところ,Ubuntu 23.10以上は権限関係のデフォルトの挙動が変わっていることが原因のようでした.以下,apptainerのGitHubのApparmor Profile (Ubuntu 23.10+)から引用します.

Beginning with the 23.10 release and including the 24.04 LTS release, Ubuntu does not permit applications to create unprivileged user namespaces by default.

そこで,GitHubの記述に従い以下のコマンドでapparmor profileを作成し,apparmorを再起動することで非特権ユーザでもapptainerコンテナを起動できるようになります.

なお,apparmor profile内に記述するパスについてこちらのissueを参考に実際の自分の環境に合わせて修正しています.

sudo tee /etc/apparmor.d/apptainer << 'EOF'
# Permit unprivileged user namespace creation for apptainer starter
abi <abi/4.0>,
include <tunables/global>
profile apptainer /usr/libexec/apptainer/bin/starter{,-suid} 
    flags=(unconfined) {
  userns,
  # Site-specific additions and overrides. See local/README for details.
  include if exists <local/apptainer>
}
EOF

以下のコマンドでapparmorを再起動します.

sudo systemctl reload apparmor
sudo systemctl daemon-reload

動作テスト

以下のコマンドで動作テストします.

apptainer build lolcow.sif docker://sylabsio/lolcow
apptainer run lolcow.sif

以下のように,ウシが現在時刻を喋れば動作成功です.

 ______________________________
< Sun Apr 27 00:04:43 JST 2025 >
 ------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

apptainerとsingularityコマンド

apptainerをインストールするとsingularityコマンドも利用可能になります.実際にはsingularityコマンドがapptainerコマンドへのシンボリックリンクとなっていました.そのため,これまで通りsingularityコマンドで利用することもできそうです.

終わりに

Ubuntuを24.04でのapptainerインストールについてまとめました.Ubuntu24.04ではaptでインストールするだけでは非特権ユーザでは動かず,今回はインストール時にapparmor profileの記述を行う必要でした.

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?