Skip to content

Instantly share code, notes, and snippets.

@likwid
Last active December 16, 2019 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save likwid/86193ef581c530ea55d3 to your computer and use it in GitHub Desktop.
Save likwid/86193ef581c530ea55d3 to your computer and use it in GitHub Desktop.
Postgres with ssl in docker
#This isn't very secure, but its for demo purposes
docker run --name postgres -e POSTGRES_PASSWORD=password -d -p 54320:5432 \
-v $(pwd)/postgresql.conf:/srv/postgresql.conf \
-v $(pwd)/server.crt:/srv/server.crt \
-v $(pwd)/server.key:/srv/server.key \
-v $(pwd)/reconfigure_postgres.sh:/docker-entrypoint-initdb.d/reconfigure_postgres.sh \
postgres:9.5
###------------------------------------------------------------------------------
### CONFIGURATION
###------------------------------------------------------------------------------
data_directory = '/var/lib/postgresql/data'
hba_file = '/var/lib/postgresql/data/pg_hba.conf'
ident_file = '/var/lib/postgresql/data/pg_ident.conf'
###------------------------------------------------------------------------------
### CONNECTIONS AND AUTHENTICATION
###------------------------------------------------------------------------------
listen_addresses = '*'
port = 5432
max_connections = 100
ssl = on
ssl_cert_file = '/var/lib/postgresql/data/server.crt'
ssl_key_file = '/var/lib/postgresql/data/server.key'
shared_buffers = 128MB
#!/bin/bash
cp /srv/postgresql.conf /var/lib/postgresql/data/postgresql.conf
cp /srv/server.crt /var/lib/postgresql/data/server.crt
cp /srv/server.key /var/lib/postgresql/data/server.key
chown -R postgres: /var/lib/postgresql/data/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment