fb_pixel

Docker postgres doesn't start at build

Development | Databases
Description

I want do use a docker container to simulate my production environment, so I installed the db and the server in the same container, and not each in his own.

This is my dockerfile:

FROM debian
RUN apt update
RUN apt install postgresql-9.6 tomcat8 tomcat8-admin -y
RUN service postgresql start
RUN service postgresql status # says postgres is down
RUN su - postgres ;
RUN createdb db_example # fails !!!
RUN psql -c "CREATE USER springuser WITH PASSWORD 'test123';"
RUN exit
RUN service tomcat8 start

COPY target/App-1.0.war /var/lib/tomcat8/webapps/

CMD ["/bin/bash"]

The problem is that the database is down so I am uable to create the user and the database.
If I start the a debian docker container and do this steps per hand everything works fine.

Thanks for your help

Attachments
No attachments
Info
Description
RUN service postgresql status # says postgres is down
RUN su - postgres ;
RUN createdb db_example #
RUN psql -c "CREATE USER springuser WITH PASSWORD 'test123';"

to

RUN    /etc/init.d/postgresql start &&\
    psql --command "CREATE USER postgresondocker WITH SUPERUSER PASSWORD 'postgresondocker';" &&\
    createdb -O postgresondocker postgr



on February 05th, 2020 (10:17 pm)
All coments
This job has not been commented yet.