ckan-docker icon indicating copy to clipboard operation
ckan-docker copied to clipboard

Docker Compose - Error while starting DB container

Open iag-ggos opened this issue 2 years ago • 12 comments

I have currently the same issue described here https://github.com/ckan/ckan/issues/6027 during starting db with docker compose -f docker-compose.yml up by getting the error initdb: directory "/var/lib/postgresql/data" exists but is not empty. A change of pg_data=/var/lib/postgresql/data/db or running docker system prune before don't work. I had no problems with the last week installed ckan-docker.

Does anybody have the same issue now!?

iag-ggos avatar Aug 01 '23 15:08 iag-ggos

I'd make sure all db containers, images and volumes are completely removed before building the local images / running the containers again. Here is a reference in a recent PR that mentions the pg_data=/var/lib/postgresql/data/db config change

Screenshot 2023-08-02 at 10 39 47 am

kowh-ai avatar Aug 02 '23 09:08 kowh-ai

Thanks for your help. It worked for me by deleting files in the directory /var/lib/docker/volumes/ckan-docker_pg_data/_data. This is the directory which is mounted to /var/lib/postgresql/data in the ckan docker. So I don't have to change pg_data variable.

iag-ggos avatar Aug 04 '23 12:08 iag-ggos

any feedback on this? still having the same issues

ken-muturi avatar Aug 16 '23 06:08 ken-muturi

It all works (eventually) @ken-muturi - I suggest you remove all containers, images, networks, volumes plus run a docker system prune and then download, install etc

kowh-ai avatar Aug 16 '23 13:08 kowh-ai

image i get above even after running

docker stop $(docker ps -q); docker rm $(docker ps -aq); docker image rm $(docker image ls -q); docker network rm $(docker network ls -q); docker volume rm $(docker volume ls -q) followed by docker system prune then

docker compose build
docker compose up

ken-muturi avatar Aug 17 '23 07:08 ken-muturi

What do the db container logs say when it starts until it's reported to be unhealthy?

kowh-ai avatar Aug 17 '23 10:08 kowh-ai

here is the log https://gist.github.com/ken-muturi/85e592107769f826b1db5845759e2b10

ken-muturi avatar Aug 17 '23 11:08 ken-muturi

rename the 30_setup_test_databases.sql file to 30_setup_test_databases.sh and try again. Log looks fine to me. The errors are normal. I don't think sql file problem would cause the whole container to be unstable but you never know.

kowh-ai avatar Aug 17 '23 11:08 kowh-ai

thanks for this; i got it pass but it seems my installation has lost of issues; i even cloned the repo again;

https://gist.github.com/ken-muturi/aec8834adcccdf46a602ac05a427f6c4

ken-muturi avatar Aug 17 '23 13:08 ken-muturi

I got the same error today,

nmtoan91 avatar Sep 18 '23 00:09 nmtoan91

The 3 files have CRLF ending, changing them to LF will solve the issue from @kowh-ai 's last comment. If these file don's run on DB init, then tables, roles, and users don't get created, therefore all the rest fails.

thebe14 avatar Oct 12 '23 11:10 thebe14

docker volume prune was not enough, I had to docker volume rm ckan-docker_pg_data and make sure that the files were really gone from my FS before the database would boot.

loleg avatar Oct 18 '23 10:10 loleg