Skip to content

Instantly share code, notes, and snippets.

@jillesvangurp
Created August 14, 2018 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jillesvangurp/284dbb0a117014608c980e213ec9b391 to your computer and use it in GitHub Desktop.
Save jillesvangurp/284dbb0a117014608c980e213ec9b391 to your computer and use it in GitHub Desktop.
postgres with ssl cerficiates workaround for initdb and non empty data dir
# generate certificate and key with openssl and then mount them
version: '2.3'
postgres:
image: postgres:alpine
# specify location to the keys explicitly
command: -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key
environment:
POSTGRES_DB: mydb
POSTGRES_USER: user
POSTGRES_PASSWORD: secret
# mount outside of the data dir so you don't get errors about the data dir not being empty
volumes:
- ./ca/server.crt:/var/lib/postgresql/server.crt
- ./ca/server.key:/var/lib/postgresql/server.key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment