github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/docs/sources/examples/postgresql_service.Dockerfile (about)

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