コンテンツにスキップ

Podman

GitHub - containers/podman: Podman: A tool for managing OCI containers and pods.

PodmanはRedHat社のOSSである。

  • インストールが簡単である。
  • CLIがほぼDockerと同じらしい。
  • Dockerはデフォルトでroot権限でデーモンを動かすが、Podmanはデーモンを動かさない。
  • Dockerはコンテナを起動するのにroot権限が必要だが、Podmanでは不要である。

インストールする

1
$ sudo apt install -y podman podman-compose

検索先レジストリにdocker.ioを追加する。

3.2. コンテナーレジストリーの設定 | コンテナーの構築、実行、および管理 | Red Hat Enterprise Linux | 8 | Red Hat Documentation

1
2
$ mkdir -p ~/.config/containers
$ touch ~/.config/containers/registries.conf
~/.config/containers/registries.conf
1
2
unqualified-search-registries = ["docker.io"]
short-name-mode = "permissive"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$ podman run hello-world
WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers
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 17eec7bbc9d7 done   |
Copying config 1b44b5a3e0 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で1024未満のポートを使う

ホストでポートフォワーディングを行う。

1
$ sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

docker composeを代替する

Dockerで使用しているボリュームディレクトリがすでにあるなら、それをユーザー権限にする。

1
$ sudo chown -R $USER:$USER ollama

docker-compose.ymlにおいてDocker Hubにあるイメージを使うときは先頭にdocker.io/を付与すること。Docker ComposeはデフォルトでDocker Hubを参照するが、Podmanでは明示的にする必要がある。

1
$ podman-compose up

トラブルシューティング

TypeError: port should be either string or dict

portsの値をダブルクォーテーションでくくる。

docker-compose.yml
1
2
3
4
5
services:
  hoge:
    image: hoge:latest
    ports:
      - "8080:8080"

その他

podman compose upは上手くいかなかった。

1
2
3
4
5
6
$ podman compose up
WARN[0000] "/" is not a shared mount, this could cause issues or missing mounts with rootless containers
>>>> Executing external compose provider "/usr/libexec/docker/cli-plugins/docker-compose". Please refer to the documentation for details. <<<<

unable to get image 'Dockerイメージ': Cannot connect to the Docker daemon at unix:///run/user/1000/podman/podman.sock. Is the docker daemon running?
Error: executing /usr/libexec/docker/cli-plugins/docker-compose up: exit status 1
1
$ export DOCKER_HOST="unix:///run/podman/podman.sock"