Nextcloud on CasaOS: "dependency failed to start: container db-nextcloud is unhealthy"

I typically do not remove links, but in this instance, the decision was made due to repeated attacks from this person and I haven’t said a single word to the individual. This action ensures the continued respect and safety of our community.

Can you run this script:

Also, make sure Docker Compose is installed correctly:

After this, can you uninstall Big Bear Nextcloud and then reinstall it. Let me know of the logs after this.

I ran the script you gave me and reinstalled Big Bear Nextcloud. In CasaOS it still says: “dependency failed to start: container db-nextcloud is unhealthy”. Here are the logs from Dozzle:
2024-04-28T17:38:20.357584555Z This user must also own the server process.
2024-04-28T17:38:20.357588536Z
2024-04-28T17:38:20.357667870Z The database cluster will be initialized with locale “en_US.utf8”.
2024-04-28T17:38:20.357744334Z The default database encoding has accordingly been set to “UTF8”.
2024-04-28T17:38:20.357876113Z The default text search configuration will be set to “english”.
2024-04-28T17:38:20.357886169Z
2024-04-28T17:38:20.357889984Z Data page checksums are disabled.
2024-04-28T17:38:20.357893447Z
2024-04-28T17:38:20.464501070Z fixing permissions on existing directory /var/lib/postgresql/data … ok
2024-04-28T17:38:20.466588165Z creating subdirectories … ok
2024-04-28T17:38:20.488297890Z selecting dynamic shared memory implementation … posix
2024-04-28T17:38:20.586774892Z selecting default max_connections … 20
2024-04-28T17:38:20.884679477Z selecting default shared_buffers … 400kB
2024-04-28T17:38:20.893979999Z selecting default time zone … Etc/UTC
2024-04-28T17:38:20.896296560Z creating configuration files … ok
2024-04-28T17:38:20.957655344Z 2024-04-28 17:38:20.956 UTC [83] FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
2024-04-28T17:38:20.957706104Z 2024-04-28 17:38:20.956 UTC [83] HINT: The server must be started by the user that owns the data directory.
2024-04-28T17:38:20.962133983Z child process exited with exit code 1
2024-04-28T17:38:20.962189391Z initdb: removing contents of data directory “/var/lib/postgresql/data”
2024-04-28T17:38:21.004704128Z running bootstrap script …

PS: I’m sorry for posting the link in my 1st reply. I didn’t know but now I do.

If Docker and Docker Compose do not fix your issue, then you will need to change the permissions on the host path.

Step 1: Determine the UID and GID Inside the Container

Run a Temporary Container: Use the following Docker command to check the UID and GID of the postgres user inside your specific PostgreSQL Docker image:

docker run --rm -it postgres:14.2 id postgres

This command runs a temporary instance of the PostgreSQL container and executes the id command for the postgres user, which will output the user’s UID and GID.

Step 2: Adjust Permissions on the Host Directory

Adjust Host Directory Permissions: Once you know the UID and GID, apply these to the host directory that you are mounting as the data volume for PostgreSQL. You can do this with:

sudo chown -R [UID]:[GID] /DATA/AppData/big-bear-nextcloud/pgdata
sudo chmod -R 700 /DATA/AppData/big-bear-nextcloud/pgdata

Replace [UID] and [GID] with the values obtained from step 1. For example, if the output from the id command was uid=999(postgres) gid=999(postgres), you would use 999:999.The chown command changes the ownership of the directory to match that required by the PostgreSQL process inside the container, and chmod 700 sets the permissions so that only the owner can read, write, and execute in the directory.

No problem, thanks for understanding!

So, i tried to run the first command in your post, but i get this error message: “docker: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Head “http://%2Fvar%2Frun%2Fdocker.sock/_ping”: dial unix /var/run/docker.sock: connect: permission denied.”.

Your current user doesn’t have permission to access the Docker daemon, which is typically restricted to the root user.

Add Your User to the Docker Group

This method allows your user to run Docker commands without needing root access. You can do this by running:

sudo usermod -aG docker $USER

After this, log out and log back in to apply the group changes. This is generally the recommended approach for development environments.

After I did all the instrructions you gave me (they worked), it still gives me the same error in CasaOS. Here are the logs from Dozzle:
2024-04-28T18:02:18.637673874Z This user must also own the server process.
2024-04-28T18:02:18.637693393Z
2024-04-28T18:02:18.637810947Z The database cluster will be initialized with locale “en_US.utf8”.
2024-04-28T18:02:18.637837003Z The default database encoding has accordingly been set to “UTF8”.
2024-04-28T18:02:18.637886021Z The default text search configuration will be set to “english”.
2024-04-28T18:02:18.637908780Z
2024-04-28T18:02:18.638035001Z Data page checksums are disabled.
2024-04-28T18:02:18.638044594Z
2024-04-28T18:02:18.638206092Z fixing permissions on existing directory /var/lib/postgresql/data … ok
2024-04-28T18:02:18.639248066Z creating subdirectories … ok
2024-04-28T18:02:18.639574971Z selecting dynamic shared memory implementation … posix
2024-04-28T18:02:18.708877327Z selecting default max_connections … 20
2024-04-28T18:02:18.978870339Z selecting default shared_buffers … 400kB
2024-04-28T18:02:18.991836650Z selecting default time zone … Etc/UTC
2024-04-28T18:02:18.994236021Z creating configuration files … ok
2024-04-28T18:02:19.035218800Z 2024-04-28 18:02:19.035 UTC [83] FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
2024-04-28T18:02:19.035269504Z 2024-04-28 18:02:19.035 UTC [83] HINT: The server must be started by the user that owns the data directory.
2024-04-28T18:02:19.040423208Z child process exited with exit code 1
2024-04-28T18:02:19.040461985Z initdb: removing contents of data directory “/var/lib/postgresql/data”
2024-04-28T18:02:19.073674767Z running bootstrap script …

Weird:

Run:

docker run --rm -it -v /DATA/AppData/big-bear-nextcloud/pgdata:/var/lib/postgresql/data postgres:14.2 bash

Once inside, check the ownership with:

ls -ld /var/lib/postgresql/data

So i did that thru SSH, and it just gave me “total 0”

Yes I missed typed it’s:

ls -ld /var/lib/postgresql/data

I ran it again and now it gave me something different:
“drwxrwxrwx 1 root root 4096 Apr 28 18:20 /var/lib/postgresql/data”

That’s normally the wrong permission. You can try to change the permissions again on the host or you can add to the db-nextcloud service:

user: "999:999" # Run as non-root user

You can edit the docker compose with:

You could also manually create the directory and don’t let docker do it before installing the nextcloud:

sudo mkdir -p /DATA/AppData/big-bear-nextcloud/pgdata
sudo chown -R 999:999 /DATA/AppData/big-bear-nextcloud/pgdata
sudo chmod -R 700 /DATA/AppData/big-bear-nextcloud/pgdata

Could you try in big-bear-casaos the Nextcloud LS?

Hello. I’m sorry for the late reply. I tried the script with big-bear-nextcloud. When i opened it with nano, it said at the bottom “[ Error reading /var/lib/casaos/apps/big-bear-nextcloud/docker-compose.yml: Permission denied ]” and the file was empty. This is the output of the script after i ran it.

utilizator@raspberrypi:~ $ bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/edit-casaos-apps/run.sh)"
Welcome to the CasaOS App Editor.
Available apps:
big-bear-dozzle  big-bear-nextcloud  calibre-web  jellyfin  lidarr  nextcloud  radarr  sonarr  uplifting_rik
Enter the name of the app you want to edit: big-bear-nextcloud
Please select an editor:
1. nano
2. vim
Enter your choice (1 or 2): 1
environment: line 13: 471847 Segmentation fault      casaos-cli app-management apply "$service_name" --file="$docker_compose_path"
Editing complete.

I also tried to manually create the folders and reinstalling big-bear-nextcloud.

PS: What do you mean by Nextcloud LS?

There is an app in BigBearCasaOS that I added so maybe I can figure out if it will work with your PI 5. It’s hard to reproduce this issue when I don’t have a Pi 5.

I’m sorry but in my CasaOS App Store there is no Nextcloud LS in my BigBearCasaOS source. I have added LinuxServer as a source and their nextcloud shows up. Here is a screenshot:

Can you try to remove the BigBearCasaOS store and re-add it?

With so many glitches happening with your system, you might think about reinstalling CasaOS, which sometimes fixes a lot of issues for people.

I tried to re-add BigBearCasaOS and it still doesn’t show up. Maybe it’s because i have LinuxServer already set as a source? Anyway, will reinstalling CasaOS remove my data?

You will need to watch the prompts and don’t delete the AppData. I would recommend a backup before running the reinstall.

You docker compose is at:

/var/lib/casaos/apps/

AppData is at:

/DATA/AppData/*