Configure dockerfile with postgres

0 votes

I have a specific requirement for my app. Am trying to make Dockerfile for postgres db.

My dockerfile:

FROM postgres:9.4
RUN mkdir /sql
COPY src/main/resources/sql_scripts/* /sql/
RUN psql -f /sql/create_user.sql
RUN psql -U user -W 123 -f create_db.sql
RUN psql -U user -W 123 -d school_ats -f create_tables.sql

My build command

docker build .

Output

Sending build context to Docker daemon 3.367 MB
Step 1 : FROM postgres:9.4
 ---> 6196bca94565
Step 2 : RUN mkdir /sql
 ---> Using cache
 ---> 6f57c1e759b7
Step 3 : COPY src/main/resources/sql_scripts/* /sql/
 ---> Using cache
 ---> 3b496bfb28cd
Step 4 : RUN psql -a -f /sql/create_user.sql
 ---> Running in 33b2230a12fa
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
The command '/bin/sh -c psql -a -f /sql/create_user.sql' returned a non-zero code: 2

Is there a way to specify me db to the docker?

Apr 29, 2022 in Docker by Abhijeet
• 180 points

edited 5 days ago 6 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP