Building my own postgresql image

The image is built successfully, but I want to create the database on it at the time it is built. Everytime I do so it gives me the error that the postgresql is down.
When I create/build the image without that script which is suppose to create the databases it works fine.
How can I get the databases created at the time I am building the image with Dockerfile ?
Part of my Dockerfile is as follows

VOLUME ["/var/lib/pgsql"]
USER postgres
CMD ["/bin/bash", “/usr/local/bin/”]

RUN /var/lib/pgsql/

you need to start the database on your own in a RUN statement and within the same RUN statement you also need to run your database setup script ( after that shut down the database again.
Should write this in a little script.

Could look similar to this:

sleep 2m