4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Podman使ってみた & Dockerとの違いは?

Posted at

概要

Podman という Docker に互換性のあるオープンソースツールがあるということなので、勉強がてら少しだけ触ってみて Docker との違いとかを調べてみたほぼ私的な備忘録です。

Podmanとは?

Podman(POD Manager) とは RedHat 社が開発したオープンソースのコンテナ管理ツールのこと。

Red Hat Enterprise Linux 8、CentOS 8 (あるいはその後継である Rocky Linux 8 や AlmaLinux 8) では Docker の利用は非推奨となり、代わりに Podman を利用することが推奨されてるらしい。

ちなみにPodmanの公式Docsでは以下のような感じで書かれている。

Podman はデーモンレスでオープンソースの Linux ネイティブツールであり、Open Containers Initiative ( OCI )コンテナとコンテナイメージを使用してアプリケーションを簡単に検索、実行、構築、共有、デプロイできるように設計されています。
Podman は、Docker Container Engine を使用したことがある人なら誰でも使い慣れたコマンドラインインターフェース (CLI) を提供します。
ほとんどのユーザーは、問題なくDocker を Podman にエイリアスするだけです ( alias docker=podman )。

alias docker = podman と書かれているということはほぼ Docker といっても過言ではないということなのか?

Docker と Podman って何が違うの?

ここからは Podman と Docker の違いについて調べたことをつらつらと書いていきます。

Docker

  • Docker ではデーモンでコンテナレジストリ、イメージ、コンテナ、Linux カーネルを利用した作業を担っている
  • デーモンがあるので、利用側は Docker CLI にてコマンドを入力することで、上記作業自体は Docker デーモンが実行してくれる
  • デーモンは操作性の観点で、メリットが大きいが、以下のデメリットもある 引用元
  • 1つのプロセスが1つの障害点になる可能性がある
  • このプロセスはすべての子プロセス(実行中のコンテナ)を所有する
  • 障害が発生した場合、孤児(orphan)となるプロセスが存在する
  • すべての Docker の操作は、同一の完全な root 権限を持つユーザーによって行われなければならなかった

Podman

  • Docker がデーモンで動いているが、Podman はデーモンレスで Docker に似たコマンドを使用できるエンジン
  • Docker の部分でも説明があったが、Podmanではコンテナを rootless(root権限で起動しない)で起動ができる。

補足
※従来の Docker では rootless モードをサポートしていなかったが Docker Engine v19.03 から Docker でもサポートされるようになりました。(v20.10以降正式サポートされたらしい?) [1]
そのため、Docker との違いは Podman では rootless 起動がデフォルトであるという部分ということになりそう。

Podman をちょっとだけ触ってみる。

とりあえず、理解は進んでいないがちょっとだけ触ってみる。
今回環境は Rocky Linux 8 上で行ってみた。

OS情報
$ cat /etc/redhat-release 
Rocky Linux release 8.10 (Green Obsidian)

インストール

まずはインストールしなきゃ始まらないので以下コマンドでインストールする。

$ sudo yum install podman

インストール出来たらちゃんとできているかバージョン確認もしてみる

$ podman -v
podman version 4.9.4-rhel

$ podman version
Client:       Podman Engine
Version:      4.9.4-rhel
API Version:  4.9.4-rhel
Go Version:   go1.21.9 (Red Hat 1.21.9-1.module+el8.10.0+1814+f68f8a63)
Built:        Sat Jun  1 02:12:43 2024
OS/Arch:      linux/amd64

ちゃんとインストールされていれば上記のような感じで出てくるみたい。
-vオプションじゃなくversionで実行すれば詳細が見られる。

コンテナ起動

とりあえず、雑にコンテナを起動してみたいので DockerHub 上にある Hello-World なコンテナを起動してみる。

]$ podman run docker.io/hello-world:latest
Trying to pull docker.io/library/hello-world:latest...
Getting image source signatures
Copying blob c1ec31eb5944 done   | 
Copying config d2c94e258d done   | 
Writing manifest to image destination

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/

とりあえず、出来たようで一安心。
基本的なコマンドも実行してみることに。

$ podman ps -a
CONTAINER ID  IMAGE                                 COMMAND     CREATED         STATUS                     PORTS       NAMES
a1c3be9214e5  docker.io/library/hello-world:latest  /hello      29 seconds ago  Exited (0) 29 seconds ago              cool_babbage
$ podman rm cool_babbage
cool_babbage
$ podman ps
CONTAINER ID  IMAGE 
$ podman image ls
REPOSITORY                     TAG         IMAGE ID      CREATED        SIZE
docker.io/library/hello-world  latest      d2c94e258dcb  13 months ago  28.5 kB

イメージ自体はローカルに残っている、ここも Docker とは体感は変わりないことが分かる。
続いて、試しに nginx のコンテナを起動してコンテナに入れるかの確認をしてみることに。

$ podman run -d -p 8080:80 docker.io/nginx:latest
Trying to pull docker.io/library/nginx:latest...
Getting image source signatures
Copying blob b7923aa4e8a6 done   | 
Copying blob 09f376ebb190 done   | 
Copying blob 9b3addd3eb3d done   | 
Copying blob 5529e0792248 done   | 
Copying blob 57910a8c4316 done   | 
Copying blob 7b5f78f21449 done   | 
Copying blob 785625911f12 done   | 
Copying config 4f67c83422 done   | 
Writing manifest to image destination
012d874800ab70d0b1ceff7584a8a6afe13060aabaa2b45114e53fa60f85a129

$ podman ps
CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS         PORTS                 NAMES
012d874800ab  docker.io/library/nginx:latest  nginx -g daemon o...  16 minutes ago  Up 16 minutes  0.0.0.0:8080->80/tcp  nice_franklin

$ podman exec  -it nice_franklin /bin/bash
root@012d874800ab:/# 
root@012d874800ab:/# echo test > /usr/share/nginx/html/index.html 
root@012d874800ab:/# cat /usr/share/nginx/html/index.html 
test

Docker と同じく exec を使うことでコンテナに入ることも可能なことが分かった。

まとめ

本当はこの Podman を使って軽い構築までやろうとしたが、今回はここまで。
Podman を使ってみた感触的には Docker と変わりない。
コマンド自体も Docker と基本は同じで docker か podman かの違いくらいであることが分かった。
次の機会があったら Podman を使って何かしらを構築したいと思う。

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?