Ubuntu 22.04にPodmanをインストールする方法
Ubuntu 22.04にPodmanをインストールする方法
このチュートリアルはこれらのOSバージョンのために存在します
- Ubuntu 22.04 (ジャミー・ジェリーフィッシュ)
- Ubuntu 20.04 (フォーカルフォッサ)
このページで
- 前提条件
- Ubuntu 22.04にPodmanをインストールする
- Podmanレジストリを設定する
- Podmanを使用して画像をダウンロードする
- Podmanを使用してコンテナを作成および管理する
- Podmanを始める
- 結論
Podman(ポッドマネージャーとも呼ばれる)は、コンテナを作成し管理するために使用されるオープンソースツールです。これは、Dockerデーモンに依存せず、Dockerと互換性のあるlibpodライブラリの一部です。Kubernetes向けのシンプルで軽量なコンテナランタイム環境です。最近のDockerライセンスの変更により、PodmanはほとんどのLinuxシステムで使用できる良い代替手段になる可能性があります。
このチュートリアルでは、Ubuntu 22.04サーバーにPodmanをインストールして使用する方法を説明します。
前提条件
- Ubuntu 22.04を実行しているサーバー。
- サーバーにはルートパスワードが設定されています。
Ubuntu 22.04にPodmanをインストールする
デフォルトでは、PodmanパッケージはUbuntuのデフォルトリポジトリに含まれています。次のコマンドを実行するだけでインストールできます:
apt install podman -yPodmanがインストールされたら、以下のコマンドで確認できます:
podman -v次の出力にPodmanのバージョンが表示されるはずです:
podman version 3.4.4
次のコマンドを使用して、Podmanの詳細情報も見ることができます:
podman info次の出力を得るべきです:
host:
arch: amd64
buildahVersion: 1.23.1
cgroupControllers:
- cpuset
- cpu
- io
- memory
- hugetlb
- pids
- rdma
- misc
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: 'conmon: /usr/bin/conmon'
path: /usr/bin/conmon
version: 'conmon version 2.0.25, commit: unknown'
cpus: 2
distribution:
codename: jammy
distribution: ubuntu
version: "22.04"
eventLogger: journald
hostname: ubuntu2204
idMappings:
Podmanレジストリを設定する
デフォルトでは、Podman レジストリはウェブからコンテナイメージをダウンロードおよびインストールするように設定されていません。したがって、最初に設定を行う必要があります。
nano /etc/containers/registries.conf次の行を追加してください:
[registries.search]
registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
作業が完了したら、ファイルを保存して閉じてください。
Podmanを使用して画像をダウンロードする
Podmanを使用すると、ウェブから画像を簡単に検索してダウンロードできます。たとえば、Debianイメージを検索するには、次のコマンドを実行します:
podman search debian以下の出力にすべてのDebianイメージのリストを取得する必要があります。
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/library/ubuntu Ubuntu is a Debian-based Linux operating sys... 14959 [OK]
docker.io docker.io/library/debian Debian is a Linux distribution that's compos... 4435 [OK]
docker.io docker.io/library/neurodebian NeuroDebian provides neuroscience research s... 93 [OK]
docker.io docker.io/bitnami/debian-base-buildpack Debian base compilation image 2 [OK]
docker.io docker.io/mirantis/debian-build-ubuntu-xenial 0
docker.io docker.io/mirantis/debian-build-ubuntu-trusty 0
docker.io docker.io/osrf/debian_arm64 Debian arm64 Base Images 1
docker.io docker.io/rancher/debianconsole 1
docker.io docker.io/dokken/debian-10 Debian 10 image for use with kitchen-dokken 0
docker.io docker.io/dokken/debian-9 Debian 9 image for kitchen-dokken 0
docker.io docker.io/ustclug/debian Official Debian Image with USTC Mirror 1
docker.io docker.io/dokken/debian-8 EOL: Debian 8 image for kitchen-dokken 0
docker.io docker.io/dokken/debian-11 Debian 11 image for use with kitchen-dokken 0
docker.io docker.io/corpusops/debian-bare https://github.com/corpusops/docker-images/ 0
docker.io docker.io/datadog/debian-i386 0
docker.io docker.io/corpusops/debian debian corpusops baseimage 0
docker.io docker.io/osrf/debian_armhf Debian Armhf Base Images 1
docker.io docker.io/treehouses/debian 2
docker.io docker.io/dokken/debian-7 EOL DISTRO: For use with kitchen-dokken, Bas... 0
docker.io docker.io/treehouses/debian-tags 0
docker.io docker.io/dokken/debian-12 0
docker.io docker.io/dockage/debian-runit Docker image uses runit as a process supervi... 2 [OK]
docker.io docker.io/galaxy/debian32-wheel 0
docker.io docker.io/galaxy/debian-wheel 0
docker.io docker.io/dockage/debian Debian image that forms the base for some Do... 2 [OK]
次に、以下のコマンドを使用してインターネットから最新のDebianイメージをダウンロードします:
podman pull debianこれにより、以下に示す最新のDebianイメージを検索してダウンロードします:
Getting image source signatures
Copying blob 23858da423a6 done
Copying config 43d28810c1 done
Writing manifest to image destination
Storing signatures
43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a
次のコマンドを使用して、ダウンロードした画像を確認できます:
podman images
次の出力が表示されるはずです:
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/debian latest 43d28810c1b4 5 days ago 129 MB
Podmanを使用してコンテナを作成および管理する
Podmanを使用すると、コマンドラインを通じて簡単にコンテナを作成および管理できます。
Debianイメージからコンテナを作成するには、次のコマンドを実行します:
podman run -dit --name debian-container debianコンテナが作成されると、次のコマンドを使用して実行中のコンテナを見ることができます:
podman ps次の出力が表示されるはずです:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
533698eaf6f1 docker.io/library/debian:latest bash 6 seconds ago Up 6 seconds ago debian-container
Debianコンテナに接続するには、以下のコマンドを実行してください:
podman attach debian-container以下のように、Debianコンテナに入ります:
root@533698eaf6f1:/#
次のコマンドでコンテナのバージョンを確認できます:
cat /etc/os-release次の出力が得られます:
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
コンテナから退出するには、次のコマンドを実行してください:
root@533698eaf6f1:/# exit
コンテナを停止するには、以下のコマンドを実行してください:
podman stop debian-containerコンテナを開始するには、以下のコマンドを実行してください:
podman start debian-containerコンテナを削除するには、次のコマンドを実行してください:
podman rm debian-containerDebianイメージを削除するには、次のコマンドを実行してください:
podman rmi debian次の出力が得られます:
Untagged: docker.io/library/debian:latest
Deleted: 43d28810c1b4c28a1be3bac8e0e40fcc472b2bfcfcda952544ed99cb874d2b1a
次のコマンドを使用して、すべてのPodmanコマンドオプションを一覧表示できます。
podman --help次の出力にすべての便利なオプションが表示されるはずです。
Manage pods, containers and images
Usage:
podman [options] [command]
Available Commands:
attach Attach to a running container
auto-update Auto update containers according to their auto-update policy
build Build an image using instructions from Containerfiles
commit Create new image based on the changed container
container Manage containers
cp Copy files/folders between a container and the local filesystem
create Create but do not start a container
diff Display the changes to the object's file system
events Show podman events
exec Run a process in a running container
export Export container's filesystem contents as a tar archive
generate Generate structured data based on containers, pods or volumes
healthcheck Manage health checks on containers
help Help about any command
history Show history of a specified image
image Manage images
images List images in local storage
import Import a tarball to create a filesystem image
info Display podman system information
init Initialize one or more containers
inspect Display the configuration of object denoted by ID
kill Kill one or more running containers with a specific signal
load Load image(s) from a tar archive
login Login to a container registry
logout Logout of a container registry
logs Fetch the logs of one or more containers
machine Manage a virtual machine
manifest Manipulate manifest lists and image indexes
mount Mount a working container's root filesystem
network Manage networks
pause Pause all the processes in one or more containers
play Play containers, pods or volumes from a structured file
pod Manage pods
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image from a registry
push Push an image to a specified destination
rename Rename an existing container
restart Restart one or more containers
rm Remove one or more containers
rmi Removes one or more images from local storage
run Run a command in a new container
save Save image(s) to an archive
search Search registry for image
secret Manage secrets
start Start one or more containers
stats Display a live stream of container resource usage statistics
stop Stop one or more containers
system Manage podman
tag Add an additional name to a local image
top Display the running processes of a container
unmount Unmounts working container's root filesystem
unpause Unpause the processes in one or more containers
unshare Run a command in a modified user namespace
untag Remove a name from a local image
version Display the Podman version information
volume Manage volumes
wait Block on one or more containers
Podmanを始める
Podmanを使用して画像、ボリューム、およびコンテナを作成する方法に関する詳細なガイドはこちらにあります: Podmanを使い始める: 画像、コンテナ、ボリュームを管理する
結論
おめでとうございます!あなたはUbuntu 22.04サーバーにPodmanを正常にインストールしました。これで、コンテナを管理するためのDockerの代替ツールとしてPodmanを使用できるようになりました。何か質問があれば遠慮なく聞いてください。Podmanに関する詳細情報は、Podmanのドキュメンテーションページを訪れてください。