Dockerfile 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. FROM ubuntu
  2. # Add the PostgreSQL PGP key to verify their Debian packages.
  3. # It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
  4. RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
  5. # Add PostgreSQL's repository. It contains the most recent stable release
  6. # of PostgreSQL, ``9.3``.
  7. RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
  8. # Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3
  9. # There are some warnings (in red) that show up during the build. You can hide
  10. # them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
  11. RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3
  12. # Note: The official Debian and Ubuntu images automatically ``apt-get clean``
  13. # after each ``apt-get``
  14. # Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed``
  15. USER postgres
  16. # Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
  17. # then create a database `docker` owned by the ``docker`` role.
  18. # Note: here we use ``&&\`` to run commands one after the other - the ``\``
  19. # allows the RUN command to span multiple lines.
  20. RUN /etc/init.d/postgresql start &&\
  21. psql --command "CREATE USER grafana WITH SUPERUSER PASSWORD 'grafana';" &&\
  22. createdb -O grafana grafana
  23. # Adjust PostgreSQL configuration so that remote connections to the
  24. # database are possible.
  25. RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf
  26. # And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf``
  27. RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf
  28. # Expose the PostgreSQL port
  29. EXPOSE 5432
  30. # Add VOLUMEs to allow backup of config, logs and databases
  31. VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
  32. # Set the default command to run when starting the container
  33. CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"]