Skip to content

Instantly share code, notes, and snippets.

@ypwu1
Forked from likwid/docker_command
Created May 11, 2017 20:40
Show Gist options
  • Save ypwu1/36d0ecf2740fbbbd63bd2514c0072855 to your computer and use it in GitHub Desktop.
Save ypwu1/36d0ecf2740fbbbd63bd2514c0072855 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