Thursday, November 27, 2025

 

Podman : Use by common users

 

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

63758
# sub UID/GID mapping file
# 100000 to 165535 (100000 + 65536 - 1) UID are used for running processes in containers on [debian] user

root@dlp:~# 
cat /etc/subuid

debian:100000:65536
root@dlp:~# 
cat /etc/subgid

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

root@dlp:~# 
adduser bookworm

root@dlp:~# 
adduser trixie

root@dlp:~# 
cat /etc/subgid /etc/subgid

debian:100000:65536
bookworm:165536:65536
trixie:231072:65536
debian:100000:65536
bookworm:165536:65536
trixie:231072:65536
[2]It's possible to run [podman] by common users.
debian@dlp:~$ 
podman pull debian

debian@dlp:~$ 
podman images

REPOSITORY                TAG         IMAGE ID      CREATED      SIZE
docker.io/library/debian  latest      047bd8d81940  11 days ago  124 MB

debian@dlp:~$ 
podman run debian echo "run rootless containers"

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

debian@dlp:~$ 
ll ~/.local/share/containers/storage

total 156
-rw-r--r-- 1 debian debian 122880 Aug 22 10:22 db.sql
-rw-r--r-- 1 debian debian      8 Aug 22 10:22 defaultNetworkBackend
drwx------ 2 debian debian   4096 Aug 22 10:22 libpod
drwx------ 2 debian debian   4096 Aug 22 10:22 networks
drwx------ 5 debian debian   4096 Aug 22 10:22 overlay
drwx------ 3 debian debian   4096 Aug 22 10:22 overlay-containers
drwx------ 3 debian debian   4096 Aug 22 10:22 overlay-images
drwx------ 2 debian debian   4096 Aug 22 10:22 overlay-layers
-rw-r--r-- 1 debian debian     64 Aug 22 10:22 storage.lock
-rw-r--r-- 1 debian debian      0 Aug 22 10:22 userns.lock
drwx------ 2 debian debian   4096 Aug 22 10:22 volumes

# possible to create Pods

debian@dlp:~$ 
podman pod create -p 8081:80 -n test-pod

debian@dlp:~$ 
podman pod ls

POD ID        NAME        STATUS      CREATED        INFRA ID      # OF CONTAINERS
e2db14b02995  test-pod    Created     4 seconds ago  735e59f65179  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

debian@dlp:~$ 
podman run -itd -p 1023:80 debian /bin/bash

Error: pasta failed with exit code 1:
Failed to bind port 1023 (Permission denied) for option '-t 1023-1023:80-80'
debian@dlp:~$ 
podman run -itd -p 1024:80 debian /bin/bash

debian@dlp:~$ 
podman ps

CONTAINER ID  IMAGE                            COMMAND     CREATED        STATUS        PORTS                 NAMES
81c9cd6a7fd0  docker.io/library/debian:latest  /bin/bash   2 seconds ago  Up 2 seconds  0.0.0.0:1024->80/tcp  nice_shamir

No comments:

Post a Comment