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

Hello everyone. I installed Nextcloud on a RaspberryPi 5 (running CasaOS) using big-bear-casaos by following this tutorial, but after i followed the steps of adding big-bear-casaos as a source for the app store and installing Nextcloud from there, everytime I try to open it, it just says: “dependency failed to start: container db-nextcloud is unhealthy”. Has this happened to anyone else? Can someone help me fix this?

Can you look at the logs on the db-nextcloud?

Here are the logs that were made for redis-nextcloud (it was the only one for big-bear-nextcloud in Dozzle):
2024-04-28T16:19:28.226208807Z 1:C 28 Apr 2024 16:19:28.225 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
2024-04-28T16:19:28.226355567Z 1:C 28 Apr 2024 16:19:28.225 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
2024-04-28T16:19:28.226363104Z 1:C 28 Apr 2024 16:19:28.225 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
2024-04-28T16:19:28.226836661Z 1:M 28 Apr 2024 16:19:28.226 * monotonic clock: POSIX clock_gettime
2024-04-28T16:19:28.230677225Z 1:M 28 Apr 2024 16:19:28.230 * Running mode=standalone, port=6379.
2024-04-28T16:19:28.230705966Z 1:M 28 Apr 2024 16:19:28.230 # Server initialized
2024-04-28T16:19:28.230741632Z 1:M 28 Apr 2024 16:19:28.230 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ‘vm.overcommit_memory = 1’ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.overcommit_memory=1’ for this to take effect.
2024-04-28T16:19:28.242494399Z 1:M 28 Apr 2024 16:19:28.242 * Ready to accept connections

I eventually gave up trying to make this version of nextcloud work and followed another tutorial (Link Removed by Admin), and it worked after some light troubleshooting.

You would need to go to the cog top right, then scroll down to show stopped containers and turn on. The only thing about that is that you will not get updates automatically.

I just went ahead and tried to install it myself, and it started right away. So I would need the logs for the stopped container since I can’t reproduce it.

Here are the logs that were made for nextcloud-db:
2024-04-28T16:41:12.269225229Z This user must also own the server process.
2024-04-28T16:41:12.269237655Z
2024-04-28T16:41:12.269253303Z The database cluster will be initialized with locale “en_US.utf8”.
2024-04-28T16:41:12.269257044Z The default database encoding has accordingly been set to “UTF8”.
2024-04-28T16:41:12.269260081Z The default text search configuration will be set to “english”.
2024-04-28T16:41:12.269263525Z
2024-04-28T16:41:12.269265933Z Data page checksums are disabled.
2024-04-28T16:41:12.269284155Z
2024-04-28T16:41:12.269539025Z fixing permissions on existing directory /var/lib/postgresql/data … ok
2024-04-28T16:41:12.270766803Z creating subdirectories … ok
2024-04-28T16:41:12.271083007Z selecting dynamic shared memory implementation … posix
2024-04-28T16:41:12.379720397Z selecting default max_connections … 20
2024-04-28T16:41:12.745788369Z selecting default shared_buffers … 400kB
2024-04-28T16:41:12.759616020Z selecting default time zone … Etc/UTC
2024-04-28T16:41:12.763163872Z creating configuration files … ok
2024-04-28T16:41:12.789323562Z 2024-04-28 16:41:12.788 UTC [83] FATAL: data directory “/var/lib/postgresql/data” has wrong ownership
2024-04-28T16:41:12.789392636Z 2024-04-28 16:41:12.788 UTC [83] HINT: The server must be started by the user that owns the data directory.
2024-04-28T16:41:12.794470156Z child process exited with exit code 1
2024-04-28T16:41:12.794537322Z initdb: removing contents of data directory “/var/lib/postgresql/data”
2024-04-28T16:41:12.838109885Z running bootstrap script …
And after it does all of that it just stops.

How did you install Docker?

When i ran the CasaOS install script it automatically installed docker.

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