2021年3月24日水曜日

Debian 11 で Rootless Podman を試す

Debian 11 だと apt でインストールできるようなので、それでサクッと試す。

前提条件

Podman のインストール

pull 時に TLS 通信が使われるので、 ca-certificates もインストールする。

sudo apt-get update
sudo apt-get install -y podman ca-certificates

とりあえず rootfull で podman が実行できることを確認。

mikoto@debian:~$ sudo podman run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

OK.

Rootless のための準備

一般ユーザーが名前空間を作成できるようにカーネルパラメーターを更新。

sudo bash -c 'echo "user.max_user_namespaces=28633" > /etc/sysctl.d/userns.conf'
sudo sysctl -p /etc/sysctl.d/userns.conf

この後作成するユーザーについては、rootless podman を実行するための設定が有効になる。

現在のログインユーザーが、名前空間を作成できるようにするためには、マシンの再起動が必要。 (他に方法があると思うが、今回再ログインでもダメだったので再起動した…)

動作確認

mikoto@debian:~$ podman run hello-world
Resolved "hello-world" as an alias (/etc/containers/registries.conf.d/shortnames.conf)
Trying to pull docker.io/library/hello-world:latest...
Getting image source signatures
Copying blob b8dfde127a29 done
Copying config d1165f2212 done
Writing manifest to image destination
Storing signatures

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

以上。

参考資料