いつからだったか忘れましたが、Docker Desktop を会社で利用する場合、会社の規模によっては別途ライセンス購入が必要になりました。Docker 単体であれば問題なかったはず。代替ツールとして、Docker 同様にコンテナーが扱える Podman が候補にあがります。そこで今回は、Podman を実際に試してみました。
Podman をインストール
# mac に podman をインストール
$ brew install podman
# podman を初期化
$ podman machine init
# podman を起動
$ podman machine start
# podman 情報を表示
$ podman info
# podman バージョンを表示
$ podman --version
podman version 5.0.3
Podman の動作確認
# コンテナーイメージを検索
$ podman search httpd --filter=is-official
NAME DESCRIPTION
docker.io/library/httpd The Apache HTTP Server Project
# コンテナーイメージをダウンロード
$ podman pull docker.io/library/httpd
# ダウンロードしたコンテナーイメージ一覧を表示
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/library/httpd latest c569911b4d23 2 months ago 181 MB
# httpd コンテナーを起動
$ podman run -d -p 8080:80/tcp docker.io/library/httpd
# 起動中のコンテナー一覧を表示
$ podman ps
ONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82a9452f76ce docker.io/library/httpd:latest httpd-foreground 12 seconds ago Up 12 seconds 0.0.0.0:8080->80/tcp distracted_bassi
# httpd コンテナーのポートにアクセス
$ curl http://localhost:8080
<html><body><h1>It works!</h1></body></html>
# httpd コンテナーのログ表示
$ podman logs -f 82a9452f76ce
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.2. Set the 'ServerName' directive globally to suppress this message
[Sun Jun 30 01:13:06.209249 2024] [mpm_event:notice] [pid 1:tid 281473098027040] AH00489: Apache/2.4.59 (Unix) configured -- resuming normal operations
[Sun Jun 30 01:13:06.209337 2024] [core:notice] [pid 1:tid 281473098027040] AH00094: Command line: 'httpd -D FOREGROUND'
10.88.0.2 - - [30/Jun/2024:01:13:36 +0000] "GET / HTTP/1.1" 200 45
# httpd コンテナーを停止
$ podman stop 82a9452f76ce
# 停止済みのコンテナーを含むコンテナー一覧を表示
$ podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82a9452f76ce docker.io/library/httpd:latest httpd-foreground 2 minutes ago Exited (0) 5 seconds ago 0.0.0.0:8080->80/tcp distracted_bassi
# 停止した httpd コンテナーを削除
$ podman rm 82a9452f76ce
# ダウンロードした httpd コンテナーを削除
$ podman rmi docker.io/library/httpd
# ダウンロードしたコンテナー一覧が空になった事を確認
$ podman images
# podman を停止
$ podman machine stop
Podman Desktop を別途インストール
