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 –

  • Google Container Engine stdout Logs Not Showing Up
  • Can a Docker container be started directly from Bluemix Workload Scheduler?
  • Docker: How to use selenium server to do nightwatchJS test?
  • docker-compose + external container
  • Gitlab pipeline fails during connect with EOF
  • How many containers should exist per host in production? How should services be split?
  • 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 /root/
    RUN cd ~
    RUN (curl -O && \
    rpm -ivh pgdg* && \
    yum list postgres* && \
    yum install -y  postgresql93-server && \
    service postgresql-9.3 initdb)
    echo "sh /root/" >> ~/.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 ( 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.



  • Why am I getting UTF-8 invalid bye sequence ArgumentErrors in dotenv only on EC2?
  • how to list Docker images with Vagrant and Kubernetes
  • Unable to create spring boot initialzr project (A org.springframework.web.client.HttpClientErrorException exception has occurred)
  • Node error ENOSPC when running pm2 with docker-compose
  • How to deploy a wolkenkit application to digital ocean?
  • How to persist Docker data in HOST
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.