Hello everyone,
I’m facing an issue with PostgreSQL while trying to set up my Nextcloud instance. I recently created a new Docker image for Nextcloud and ever since then, I’ve been unable to recreate it due to a PostgreSQL authentication error.
The Problem:
When I attempt to create the required PostgreSQL role “oc_rene-next,” I encounter the following error: “createuser: error: connection to server on socket ‘/var/run/postgresql/.s.PGSQL.5432’ failed: FATAL: role ‘postgres’ does not exist.” This issue is preventing me from recreating my Nextcloud setup.
What I’ve Tried:
- Manually starting PostgreSQL using the command
pg_ctl -D /var/lib/postgresql/data -l /var/log/postgresql/postgresql.log start
. - Attempting to create the “oc_rene-next” user using the
createuser
command with the--username=postgres
option. I also granted superuser privileges when prompted. - Granting all privileges on the Nextcloud database to the “oc_rene-next” user using the
GRANT
command.
Additional Information:
- My Nextcloud setup is running in Docker containers (Nextcloud, PostgreSQL, and Redis).
- I’m using the following Compose file to configure the containers:
version: '3.8'
services:
nextcloud:
image: nextcloud-custom-28:latest
container_name: nextcloud
hostname: nextcloud-server
volumes:
- /home/docker-projects/nextcloud:/var/www/html
restart: always
environment:
- POSTGRES_HOST=postgres
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
- POSTGRES_PASSWORD=securepassword
- REDIS_HOST=redis
- PHP_MEMORY_LIMIT=1024M
- NEXTCLOUD_TRUSTED_DOMAINS=localhost 192.168.178.36 nipogi nipogi.fritz.box
- NEXTCLOUD_ADMIN_USER=rene-next
- NEXTCLOUD_ADMIN_PASSWORD=rene-next#_1
- NEXTCLOUD_DEFAULT_PHONE_REGION=DE
ports:
- "8811:80"
depends_on:
- postgres
- redis
postgres:
image: postgres:latest
restart: always
environment:
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
- POSTGRES_PASSWORD=securepassword
hostname: nextcloud-db
container_name: nextcloud-db
volumes:
- /home/docker-projects/nextcloud/postgres:/var/lib/postgresql/data
redis:
image: redis:alpine
restart: always
hostname: nextcloud-redis
container_name: nextcloud-redis
I’m reaching out to the community for assistance in resolving this issue. Any help or suggestions would be greatly appreciated. Thank you!
I don’t know how to fix the problem.
I have created a new image and started the stack. But it still seems to have problems.
Maybe this is helpful:
I start the stack in Portainer, the stack file is at the top.
I create the latest Nextcloud image with a .sh file and a Dockerfile
$ cat create-nextcloud-image-28.sh
#!/bin/bash
# Setze den Namen des Docker-Images
IMAGE_NAME="nextcloud-custom-28"
OLD_IMAGES_LIMIT=2
# Alte Images umbenennen und auf maximal $OLD_IMAGES_LIMIT beschränken
# Hole die IDs der letzten zwei Images mit dem Namen $IMAGE_NAME
old_images=$(docker images --format "{{.ID}}" --no-trunc $IMAGE_NAME | head -n $OLD_IMAGES_LIMIT)
# Zähler für den Tag der alten Images
count=1
# Gehe jedes alte Image durch und benenne es um
for img in $old_images; do
new_tag="${IMAGE_NAME}-backup-${count}"
echo "Tagging image $img with $new_tag"
docker tag $img $new_tag
count=$((count + 1))
done
# Entferne alle alten Images, die nicht in den letzten $OLD_IMAGES_LIMIT sind
docker images --format "{{.ID}}" --no-trunc $IMAGE_NAME | tail -n +$((OLD_IMAGES_LIMIT + 1)) | xargs -r docker rmi
# Baue das Docker-Image mit der angegebenen Dockerfile und ohne Cache
docker build --no-cache -f Dockerfile-28 -t $IMAGE_NAME .
$ cat Dockerfile-28
# Basis-Image
FROM nextcloud:28-apache
# Installiere notwendige Pakete
RUN apt-get update && \
apt-get install -y libbz2-dev nano ffmpeg && \
rm -rf /var/lib/apt/lists/*
# Installiere PHP-Erweiterungen
RUN docker-php-ext-install bz2