Home > other >  Postgresql - Docker Postgres. On how to create database and user?
Postgresql - Docker Postgres. On how to create database and user?

Time:10-07

I am trying to use the docker create simple postgres server. I use the official postgres image as the basis of my container. My Dockerfile consists of the following commands:

The FROM postgres
The USER postgres
The RUN/etc/init. D/postgresql start & amp; & \
PSQL command to "CREATE USER USER WITH SUPERUSER PASSWORD 'USER'." & & \
Createdb -o user app

When I try to run it, I have an error:


PSQL: could not connect to server: No to the file or directory
Is the server running locally and has
Connections on the Unix domain socket "/var/run/postgresql/. Supachai panitchpakdi GSQL. 5432"?

What did I do wrong?

CodePudding user response:

Postgres may take some time to start accepting connections. The way you write it, it will be called immediately after the start () function returns the CREATE USER. Try to sleep there, take a look at it whether there is any problem.

CodePudding user response:

Through dockerfile is done, can be done when creating container by parameters, through parameter after add, enter into the container, database has a custom database
Such as docker run -- the name using the -e POSTGRES_DB=XXXX to define
  • Related