Download the Postgres image docker pull postgres:14-alpine3.14
Create a shell script in your folder called start-postgresh.sh
Paste the following in the shell script
if [ ! -d "${PGDATA_DIR}" ]
then
echo "${PGDATA_DIR} does not exists. Can not start postgres database";
echo "Please run ./docker/start-postgres.sh from the project root directory."
exit 1;
fi
PG_DB=
PG_USER=
PG_PASSWORD=
if [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
In windows use the windows path format
PGDATA_DIR=cygpath -w $PGDATA_DIR;
export MSYS_NO_PATHCONV=1
fi
Download the Postgres image docker pull postgres:14-alpine3.14 Create a shell script in your folder called start-postgresh.sh Paste the following in the shell script
!/bin/bash
PGDATA_DIR="$( pwd -P )/data" echo "${PGDATA_DIR}";
if [ ! -d "${PGDATA_DIR}" ] then echo "${PGDATA_DIR} does not exists. Can not start postgres database"; echo "Please run ./docker/start-postgres.sh from the project root directory." exit 1; fi
PG_DB=
PG_USER=
PG_PASSWORD=
if [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then
In windows use the windows path format
PGDATA_DIR=
cygpath -w $PGDATA_DIR;
export MSYS_NO_PATHCONV=1 fiecho "Using data directory ${PGDATA_DIR}"
docker run --name local-postgres \ -e POSTGRES_DB=$PG_DB \ -e POSTGRES_USER=$PG_USER \ -e POSTGRES_PASSWORD=$PG_PASSWORD \ -e 'PGDATA=/var/lib/postgresql/data/pgdata' \ -v ${PGDATA_DIR}:/var/lib/postgresql/data \ -p 5432:5432 \ -d postgres:14-alpine3.14