Fred Bongers
Fred Bongers

Reputation: 267

Docker Entrypoint for Postgres 9.3

This is my Dockerfile for installing Postgres.

# Set the base image to Ubuntu
FROM ubuntu:14.04

# Update the repository sources list
RUN apt-get update -y

################## BEGIN INSTALLATION ######################
# Install wget
RUN apt-get install wget -y

# Setup Postgres repository
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc 
| sudo apt-key add -

# Add Postgres repository
RUN sh -c "echo "deb http://apt.postgresql.org/pub/repos/apt/  trusty-pgdg main" >> /etc/apt/sources.list.d/postgresql.list"

# Update repository
RUN apt-get update -y

# Install Postgres with Postgis
RUN apt-get install postgresql-9.3-postgis-2.1 -y

How can i add an Entrypoint for Postgres so that Postgres is automatically started in a Docker-container

Upvotes: 2

Views: 673

Answers (2)

Fred Bongers
Fred Bongers

Reputation: 267

My solution to start Postgres automatic:

RUN chmod +x /etc/init.d/postgresql
CMD service postgresql start && tail -F /var/lib/postgresql/data/serverlog

Upvotes: 1

VonC
VonC

Reputation: 1328012

You can take ideas from the official docker-library/postgres Dockerfile:

ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 5432
CMD ["postgres"]

They use a docker-entrypoint.sh script which will, at the end, launch postgres

exec gosu postgres "$@"

Upvotes: 0

Related Questions