びぼうろぐ

ネ申エクセルからの卒業

【CentOS8】CentOS8でDockerの代わりにPodmanを動かしてみる

RHEL/CentOS8では Docker はサポートされないようですね😢

access.redhat.com

代わりにRedhatがサポートしているPodmanを使ってHello,Worldしてみます。

DockerとPodmanの違いは以下の記事がとても分かりやすいです。

rheb.hatenablog.com

環境情報

CentOS 8.2

Podmanのインストール

$ sudo yum install -y slirp4netns podman

Podmanのバージョン確認

$ podman version
Version:            1.6.4
RemoteAPI Version:  1
Go Version:         go1.13.4
OS/Arch:            linux/amd64

slirp4netns の役割

slirp4netns があれば PodmanはコンテナをRootlessモードで動かすことができます。

Rootlessモードは,Dockerデーモン及びコンテナを,非rootユーザで実行する技術です。 Rootlessモードを用いることにより,万一Dockerに脆弱性や設定ミスがあっても,攻撃者にホストのroot権限を奪取されることを防ぐことが出来ます。

ユーザの名前空間を増やす

$ sudo tee /etc/sysctl.d/userns.conf <<_EOF_ >/dev/null
user.max_user_namespaces=28633
_EOF_
$ sudo sysctl -p /etc/sysctl.d/userns.conf

Hello,worldしてみる

$ podman run --rm  hello-world
Trying to pull registry.access.redhat.com/hello-world...
  name unknown: Repo not found
Trying to pull registry.redhat.io/hello-world...
  unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication
Trying to pull docker.io/library/hello-world...
Getting image source signatures
Copying blob 0e03bdcc26d7 done
Copying config bf756fb1ae 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/

コンテナイメージの取得元は/etc/containers/registries.confで定義されていました。 OSがRHELサブスクリプションがあればUBIをPullするみたいですね。今回はCentOSなので、dockerhubからコンテナイメージを取得しています。

その他参考