postgresql-container icon indicating copy to clipboard operation
postgresql-container copied to clipboard

Cannot run container as non-root user

Open g4njawizard opened this issue 1 year ago • 0 comments

Container platform

Podman/Docker

Version

rhel9/postgres-13 and postgres-15. maybe 14 too..

OS version of the container image

RHEL 9

Bugzilla, Jira

No response

Description

Podman is unable to run the container with quadlet as non-root user.

I have the following systemd-file:

## Quadlet Postgres Container Service File

[Unit]
Description=Postgres Container

[Container]
Image=repo/rhel9/postgresql-15:1-28
Volume=/opt/service/postgres/data:/var/lib/pgsql/data
User=serviceuser
ContainerName=postgres
Environment=POSTGRESQL_USER=serviceuser
Environment=POSTGRESQL_PASSWORD=pw
Environment=POSTGRESQL_DATABASE=service
Environment=POSTGRESQL_ADMIN_PASSWORD=adminpw
PublishPort=5432:5432

[Service]
WorkingDirectory=/opt/home/serviceuser
Restart=always
Environment=REGISTRY_AUTH_FILE=/opt/home/serviceuser/auth_zar.json

My containers.conf

.config/containers/containers.conf

# Please refer to containers.conf(5) for details of all configuration options.
# Precedence order:
#  1. /usr/share/containers/containers.conf
#  2. /etc/containers/containers.conf
#  3. $HOME/.config/containers/containers.conf (Rootless containers ONLY)

[containers]

cgroupns = "private"
cgroups = "enabled"
cgroup_manager = "systemd"

ipcns = "private"
netns = "private"
pidns = "private"
utsns = "private"

tz = "local"

rootless_networking = "slirp4netns"

after starting as non-root:

#systemctl --user start postgres ...

Started Postgres Container.
Warning: Can't detect cpu quota from cgroups
Warning: Can't detect cpuset size from cgroups
initdb: error: cannot be run as root
initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

Reproducer

No response

g4njawizard avatar Sep 26 '23 12:09 g4njawizard