Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 794 Bytes

create-pgsql-container.md

File metadata and controls

34 lines (23 loc) · 794 Bytes

create pgsql container

docker volume create pgdata
docker run -e POSTGRES_PASSWORD=`cat ~/security/postgrespwdfile` --name postgres --mount source=pgdata,target=/var/lib/postgresql/data -d -p 5432:5432/tcp postgres:11.5

( optionally you would to specify --network=[specific-network] on docker run arguments )

data will persist between through volume ( locally mapped to /var/lib/docker/volumes/pgdata/_data )

setup your ~/.pgpass to quick access

*:*:*:postgres:secret

the format is hostname:port:database:username:password

chmod 600 ~/.pgpass

and test

psql -h localhost -U postgres

create user granting createdb

echo "CREATE USER dbuser WITH PASSWORD '$(cat ~/security/psql-user)' CREATEDB" | psql -h localhost -U postgres