Fix Permission denied: ‘/var/lib/pgadmin/sessions’ in Docker When Custom a Port

When I start my stack the pgadmin container tell the error Permission denied: '/var/lib/pgadmin/sessions'

services:
  pgadmin_storedb:
    image: dpage/pgadmin4
    container_name: pgadmin_storedb
    restart: always
    ports:
      - "5050:80"
    environment:
      PGADMIN_DEFAULT_EMAIL: pingkung@samplestore.com
      PGADMIN_DEFAULT_PASSWORD: P@ssw0rd
    volumes:
      - ./pgadmin-data:/var/lib/pgadmin
    networks:
      - store_network
    extra_hosts:
      - "host.docker.internal:host-gateway"

I change a port in my docker-compose from

services:
  pgadmin_storedb:
    image: dpage/pgadmin4
    container_name: pgadmin_storedb
    restart: always
    ports:
      - "5051:80"
    environment:
      PGADMIN_DEFAULT_EMAIL: pingkung@samplestore.com
      PGADMIN_DEFAULT_PASSWORD: P@ssw0rd
    volumes:
      - ./pgadmin-data:/var/lib/pgadmin
    networks:
      - store_network
    extra_hosts:
      - "host.docker.internal:host-gateway"

to

services:
  pgadmin_storedb:
    image: dpage/pgadmin4
    container_name: pgadmin_storedb
    restart: always
    ports:
      - "5051:5050"
    environment:
      PGADMIN_DEFAULT_EMAIL: pingkung@samplestore.com
      PGADMIN_DEFAULT_PASSWORD: P@ssw0rd
      PGADMIN_LISTEN_PORT: 5050
    volumes:
      - ./pgadmin-data:/var/lib/pgadmin
    networks:
      - store_network
    extra_hosts:
      - "host.docker.internal:host-gateway"

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.