PostgreSQL Docker installation how to setup initial database
I am pretty new to the docker technology and working on setting up the docker container with PostgreSQL setup, up and running as a service and default database created with initial schema created with the .sql file.
The docker file i am using is as below –
FROM centos:centos6 # Upgrading system #RUN yum -y upgrade RUN yum -y install wget #Installing POSTGRESQL RUN rm /etc/yum.repos.d/CentOS-Base.repo COPY CentOS-Base.repo /etc/yum.repos.d/ COPY startup.sh /root/ RUN cd ~ RUN (curl -O http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm && \ rpm -ivh pgdg* && \ yum list postgres* && \ yum install -y postgresql93-server && \ service postgresql-9.3 initdb) echo "sh /root/startup.sh" >> ~/.bashrc EXPOSE 5432
Few things which are very much required are – docker should be on Centos OS and PostgreSQL 9.3.
I am running the below startup script (startup.sh file) for post installation activities –
service postgresql-9.3 start su - postgres -c "psql -U postgres -c \"alter user postgres with password 'xxxxxxx';\""
Now when i run the docker, it does installs and start the docker but throws the below error while trying to run the alter user postgres with password ‘xxxxxxx’ command.
Any suggestions how i can run the “psql” commands like the alter password above or may be something like loading schema from .sql file post installation automatically in docker container.