DEV Community

nabbisen
nabbisen

Posted on • Originally published at scqr.net

Podman 4.3 on Artix Linux: 初期設定で発生する問題を解決

はじめに

PodmanArtix Linux という Arch Linux ベースで systemd を使っていない OS にインストールすることは、それほど難しいことではありません。
pacman が主要なパッケージを管理してくれているからです: podmanQEMUqemu-base のことです。

それらをインストールしていくつかの設定を行うことで Podman の準備を行えます。それらが完了すれば、仮想マシンを動かしてコンテナ管理を始められます ... ある程度までは。

しかし問題がいくつかは残っています。しかもプロセス制御やネットワークで問題になり得るものです。
本記事でそれらを解消する方法を記述します。

環境

問題ごとの解決方法

* doas (OpenDoas) のところは代わりに sudo も使えます。

system migrate が buildah が無いために警告

問題の内容

buildahContainers が提供する "OCI イメージのビルドを容易にするためのツール" です。
インストールされていない場合、podman system migrate が以下のワーニングを出力するでしょう:

WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers
Enter fullscreen mode Exit fullscreen mode

さらに後続の podman 操作でも同様のワーニングが出力されることがあるかもしれません。

解決方法

buildah をインストールしましょう。pacman のおかげで楽にできます:

$ doas pacman -Sy buildah
Enter fullscreen mode Exit fullscreen mode

出力とやり取りは以下の通りでした:

:: Synchronizing package databases...
(...)
resolving dependencies...
looking for conflicting packages...

Packages (2) skopeo-1.11.0-1  buildah-1.28.2-1

Total Download Size:   15.06 MiB
Total Installed Size:  52.21 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
(...)
:: Processing package changes...
(...)
Enter fullscreen mode Exit fullscreen mode

podman system migrate をもう一度実行してみましょう。エラーもワーニングも出ないのでは無いでしょうか。

gvproxy が見付からないためにネットワークが制限される

問題の内容

仮想マシンを起動した時に gvproxy が見付からずそのために "ホスト・ネットワークを起動できなかった" 旨が出力されたケースです。

$ podman machine start
Enter fullscreen mode Exit fullscreen mode

出力は以下の通りでした:

Starting machine "podman-machine-default"
Error: unable to start host networking: "could not find \"gvproxy\" in one of [/usr/local/libexec/podman /usr/local/lib/podman /usr/libexec/podman /usr/lib/podman].  To resolve this error, set the helper_binaries_dir key in the `[engine]` section of containers.conf to the directory containing your helper binaries."
Enter fullscreen mode Exit fullscreen mode

解決方法

gvproxygvisor-tap-vsock として Containers から Github で公開されています。
最新バージョン (私の場合 0.5.0 でした) を releases からダウンロードします。Linux 向けのものは gvproxy-linux という名前です。

ローカル環境で、gvproxy とリネームします。そして Podman が補助バイナリとして扱える場所に配置します。具体的にはどこでしょうか ? 上のエラーメッセージ中に候補が記されていました。なおパーミッション設定も必要です。

$ doas mv gvproxy-linux /usr/lib/podman/gvproxy

$ doas chown root:root /usr/lib/podman/gvproxy
$ doas chmod a+x /usr/lib/podman/gvproxy
Enter fullscreen mode Exit fullscreen mode

ちなみにもしかすると pacman リポジトリや AUR でパッケージを見付けることもできるかもしれません。

timedatectl が見付からないために .ign という vm 起動用ファイルがつくられない

問題の内容

Podman の ignition_linux.go にある getLocalTimeZonetimedatectl を実行します。これは systemd の一部です。そのため podman machine init は次のエラーで失敗しました:

Extracting compressed file
Image resized.
Error: exec: "timedatectl": executable file not found in $PATH
Enter fullscreen mode Exit fullscreen mode

そのため .ign というデフォルトのマシン向け起動用設定が作成されませんでした。

結果として podman machine start が次のエラーで失敗しました:

Starting machine "podman-machine-default"
Waiting for VM ...
Error: qemu exited unexpectedly with exit code 1, stderr: qemu-system-x86_64: -fw_cfg name=opt/com.coreos/config,file=/home/(...)/.config/containers/podman/machine/qemu/podman-machine-default.ign: can't load /home/(...)/.config/containers/podman/machine/qemu/podman-machine-default.ign: Failed to open file “/home/(...)/.config/containers/podman/machine/qemu/podman-machine-default.ign”: No such file or directory
Enter fullscreen mode Exit fullscreen mode

解決方法

4.4 のリリースで 解消する予定 です。

実行ファイル timedatectl を $PATH に配置しましょう... 今のうちは、なんとかして、強引にでも 😅

私が採った方法は以下の通りです:

  1. Cargo プロジェクトを作成して "timedatectl" と命名します。
  2. 私のタイムゾーンを出力するだけの Rust コードを書きます。(実行入力があっても無視します。)

    fn main() {
        println!("Asia/Tokyo");
    }
    
  3. ビルドして $PATH に配置します。実際は /usr/local/bin に配置しました。

おわりに

podman machine init が以下のように成功するはずです !!!

Extracting compressed file
Image resized.
Machine init complete
To start your machine run:

    podman machine start

Enter fullscreen mode Exit fullscreen mode

次に podman machine start を実行してみましょう。rootless モードで見事に起動するはずです 😊

Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /home/(...):/home/(...)

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command: 

    podman machine set --rootful

API forwarding listening on: /home/(...)/.local/share/containers/podman/machine/podman-machine-default/podman.sock
You can connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:

    export DOCKER_HOST='unix:///home/(...)/.local/share/containers/podman/machine/podman-machine-default/podman.sock'

Machine "podman-machine-default" started successfully
Enter fullscreen mode Exit fullscreen mode

掲載した解決方法のどれかが、あなたが Podman コンテナとポッドを快適に操作する一助となれば、幸いです。

Latest comments (0)