Giving podman permission to use /var/lib/postgresql/data on Fedora Silverblue

I’m setting up a simple postgres/node container with docker-compose but when I try to run it with podman it fails because the container doesn’t have permissions to access the database directory. When I run it with docker though the whole thing works. I’d like to be able to stick with podman so is there a permission I need to change or config for podman I’m forgetting?

I have docker-compose layered and I have tried adding :z after the path but it doesn’t change the error. I have used keep-id and tried setting the container use as postgres and root.

docker-compose.yml

services:
  web:
    image: node:lts
    working_dir: /repository
    depends_on:
      - db
    ports:
      - '3000:4000'
    volumes:
      - ./:/repository # had to add :z after repo for first launch to fix permissions
    command: 'npm start'
  db:
    image: postgres:14
    env_file: .env
    expose:
      - '5432'
    volumes:
      - lab-01-db:/var/lib/postgresql/data
volumes:
  lab-01-db:

errors:

Attaching to db-1, web-1
db-1   | chmod: changing permissions of '/var/lib/postgresql/data': Permission denied
db-1   | find: ‘/var/lib/postgresql/data’: Permission denied
db-1   | chown: changing ownership of '/var/lib/postgresql/data': Permission denied

Docker runs system containers by default (rootfull) when podman does user ones by default (rootless).

Maybe you are calling your compose command as a non-root user and asking podman to create rootless containers and it thus can not access the /var/lib/postgresql folder that is own by a system user.

You can either make sure to use system podman containers (rootfull) or use another path to store the data.

That was it, I didn’t know you could run podman with root. Thank you!

1 Like