CentOS Stream 10
Sponsored Link

Podman : Use by common users2025/01/21

 

It's possible to use Podman containers by common users.

[1] By default, sub UID/GID that are used on user name spaces are assigned to run containers.
# default name spaces number

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

62771
# sub UID/GID mapping file
# 524288 to 589823 (524288 + 65536 - 1) UID are used for running processes in containers on [fedora] user

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

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

cent:524288:65536
# when added new users, sub UID/GID are also added
# n=0, n++
# [start UID/GID = 524288 + (65536 * n)]
# [end UID/GID = (start UID/GID) + 65536 - 1]

[root@dlp ~]#
useradd redhat

[root@dlp ~]#
useradd fedora

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

cent:524288:65536
redhat:589824:65536
fedora:655360:65536
cent:524288:65536
redhat:589824:65536
fedora:655360:65536
[2] It's possible to run [podman] by common users.
[centos@dlp ~]$
podman pull centos:stream10

[centos@dlp ~]$
podman images

REPOSITORY             TAG         IMAGE ID      CREATED     SIZE
quay.io/centos/centos  stream10    1ef274445e32  7 days ago  311 MB

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

run rootless containers
# containers related files are located under the [$HOME/.local] directory

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

total 208
-rw-r--r--. 1 cent cent 188416 Jan 21 16:57 db.sql
-rw-r--r--. 1 cent cent      8 Jan 21 16:53 defaultNetworkBackend
drwx------. 2 cent cent      6 Jan 21 16:53 libpod
drwx------. 2 cent cent     27 Jan 21 16:53 networks
drwx------. 9 cent cent   4096 Jan 21 16:57 overlay
drwx------. 7 cent cent   4096 Jan 21 16:57 overlay-containers
drwx------. 3 cent cent    116 Jan 21 16:53 overlay-images
drwx------. 2 cent cent    129 Jan 21 16:57 overlay-layers
-rw-r--r--. 1 cent cent     64 Jan 21 16:57 storage.lock
-rw-r--r--. 1 cent cent      0 Jan 21 16:53 userns.lock
drwx------. 2 cent cent      6 Jan 21 16:53 volumes

# possible to create Pods

[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
2d4c49e7b9cb  test-pod    Created     4 seconds ago  facf38c19a82  1

# for port mapping,
# it's impossible to use less than [1024] ports on Host machine by common users
# possible to use over [1024] ports

[centos@dlp ~]$
podman run -d -p 1023:80 docker.io/library/nginx

Error: pasta failed with exit code 1:
Failed to bind port 1023 (Permission denied) for option '-t 1023-1023:80-80', exiting
[centos@dlp ~]$
podman run -d -p 1024:80 docker.io/library/nginx

[centos@dlp ~]$
podman ps

CONTAINER ID  IMAGE                           COMMAND               CREATED        STATUS        PORTS                 NAMES
7f5678127a8b  docker.io/library/nginx:latest  nginx -g daemon o...  3 seconds ago  Up 4 seconds  0.0.0.0:1024->80/tcp  cranky_gates
Matched Content