Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning). #178

Closed
gayanath opened this issue Jul 22, 2016 · 3 comments
Closed

Comments

@gayanath
Copy link

I am using Docker for Mac (Version 1.12.0-rc4-beta20 (build: 10404))

After creating a container, I couldn't connect to Postgres. Following is what I did to reproduce the issue, and get it working.

docker run --name postgres-1 -e POSTGRES_PASSWORD=postgres -d postgres:9.5.3
docker exec -it postgres-1 /bin/bash
root@ee38e70bca23:/# /etc/init.d/postgresql start

Above /etc/init.d/postgresql start command gave the following error.

No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning).

After googling I found http://dba.stackexchange.com/questions/50906/why-wont-postgresql-9-3-start-on-ubuntu

Ran following commands, and after that Postgres was running.

root@ee38e70bca23:/# dpkg-reconfigure locales
root@ee38e70bca23:/# pg_createcluster 9.5 main --start
root@ee38e70bca23:/# /etc/init.d/postgresql start

Running dpkg-reconfigure locales prompted me to choose a locale, and I chose en_US.utf8. How can I extend this image, and use RUN commands in a Dockerfile to avoid prompting to choose the locale?

Is this something that can be fixed in postgres image?

@yosifkit
Copy link
Member

You definitely shouldn't be running the init.d scripts in the container, since there is no init process in the container. Postgres itself is PID 1 within the container. Your first docker run command starts postgres and only postgres. docker exec is a neat trick to get an interactive shell in the same namespaces as the container so that we can inspect things.

$ docker run --name postgres-1 -e POSTGRES_PASSWORD=postgres -d postgres:9.5.3992fd0e32d3e673f2c88c43a72b4ad43e5369d7974ae9d10dec789b6d4f45029
$ docker run -it --rm postgres psql -U postgres -h ip-of-postgres-container
Password for user postgres: 
psql (9.5.3)
Type "help" for help.

postgres=# 

As for changing the locale, that is in the docs under how-to-extend-this-image. This is the source for the docs on the Docker Hub.

@gayanath
Copy link
Author

@yosifkit Thanks a lot for the explanation. For some reason, the first few times I tried the container, I couldn't connect to it from localhost even with port mapping. That's why I tried getting it working as above. Now I can connect from localhost with a command like below.

docker run --name postgres953 -e POSTGRES_PASSWORD=postgres -p 5432:5432

@waiting-for-dev
Copy link

Just in case it is useful for somebody, in my case I got that error because I was running the container with another process within it (because of a helper shell function that I didn't realize it was not right in this case). So, I was running something like:

docker run --name postgres-1 -e POSTGRES_PASSWORD=postgres -d postgres:9.5.3 tail -f /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants