CentOS 8
Sponsored Link

Podman : 一般ユーザーで利用する2019/10/11

 
一般ユーザーでも [Podman] コマンドは利用可能です。
CentOS 8 等の RHEL 8 相当のバージョン以降においては、特別な追加設定は必要ありません。
[1] デフォルトで、ユーザー名前空間で使用される サブ UID/GID が一般ユーザーに割り当てられます。
# デフォルトの名前空間の数

[root@dlp ~]#
cat /proc/sys/user/max_user_namespaces

30938
# サブ UID/GID マッピング ファイルは以下

# [100000:65536] ⇒ [cent] ユーザーは コンテナー内では

# 100000~165535 (100000 + 65536 - 1) の間の UID がプロセスの実行に使用される

[root@dlp ~]#
cat /etc/subuid

cent:100000:65536
[root@dlp ~]#
cat /etc/subgid

cent:100000:65536
# ユーザーを新規追加すると サブ UID/GID マッピング ファイルにも自動で登録される

# コンテナー内でプロセスの実行に使用される UID が各ユーザー間で重複しないように

# n=0, n++ とすると

# [開始 UID/GID = 100000 + (65536 * n)]

# [終了 UID/GID = (開始 UID/GID) + 65536 - 1] となる

[root@dlp ~]#
useradd centos

[root@dlp ~]#
useradd redhat

[root@dlp ~]#
cat /etc/subgid /etc/subgid

cent:100000:65536
centos:165536:65536
redhat:231072:65536
cent:100000:65536
centos:165536:65536
redhat:231072:65536
[2] 一般ユーザーで [podman] 使用可能です。
[centos@dlp ~]$
podman pull centos

[centos@dlp ~]$
podman images

REPOSITORY                  TAG     IMAGE ID      CREATED       SIZE
registry.centos.org/centos  latest  2f3766df23b6  3 months ago  217 MB

[centos@dlp ~]$
podman run centos echo "run rootless containers"

run rootless containers
# コンテナー関連ファイルは [$HOME/.local] 配下に保存される

[centos@dlp ~]$
ll ~/.local/share/containers/storage

total 4
drwx------. 2 centos centos  39 Mar 19 11:38 cache
drwx------. 2 centos centos  27 Mar 19 11:38 libpod
drwx------. 2 centos centos   6 Mar 19 11:38 mounts
drwx------. 5 centos centos 159 Mar 19 11:40 overlay
drwx------. 3 centos centos 124 Mar 19 11:40 overlay-containers
drwx------. 3 centos centos 116 Mar 19 11:39 overlay-images
drwx------. 2 centos centos 129 Mar 19 11:40 overlay-layers
-rw-r--r--. 1 centos centos  64 Mar 19 11:40 storage.lock
drwx------. 2 centos centos   6 Mar 19 11:38 tmp
-rw-r--r--. 1 centos centos   0 Mar 19 11:38 userns.lock

# Pod も作成可

[centos@dlp ~]$
podman pod create -p 8081:80 -n test-pod

[centos@dlp ~]$
podman pod ls

POD ID        NAME      STATUS   CREATED        INFRA ID      # OF CONTAINERS
9e99670113a1  test-pod  Created  7 seconds ago  96a40c2b7c37  1

# ポートマッピングについては

# 一般ユーザーでは ホスト側の [1024] 未満のポートは使用不可

# [1024] 以上は使用可

[centos@dlp ~]$
podman run -d -p 1023:80 srv.world/centos-nginx

Error: rootlessport cannot expose privileged port 1023, you can add 'net.ipv4.ip_unprivileged_port_start=1023' to /etc/sysctl.conf (currently 1024), or choose a larger port number (>= 1024): listen tcp 0.0.0.0:1023: bind: permission denied
[centos@dlp ~]$
podman run -d -p 1024:80 srv.world/centos-nginx

[centos@dlp ~]$
podman ps

CONTAINER ID  IMAGE                   COMMAND               CREATED             STATUS                 PORTS                 NAMES
377f620d7bf8  srv.world/centos-nginx  /usr/sbin/nginx -...  About a minute ago  Up About a minute ago  0.0.0.0:1024->80/tcp  vigilant_proskuriakova
関連コンテンツ