Thursday, September 18, 2014

Postgres As Docker

CONTAINER_NAME="postgres_server"
CONTAINER_DATA_DIR="/var/lib/postgresql/data"
HOST_PORT="55432"
POSTGRES_DOCKER_DIR=`pwd`
HOST_DATA_DIR="${POSTGRES_DOCKER_DIR}/data-dir/"

if [ ! -d "${HOST_DATA_DIR}" ]
then
    mkdir -p "${HOST_DATA_DIR}"
fi

sudo docker run --rm --name ${CONTAINER_NAME} \
            -v ${HOST_DATA_DIR}:${CONTAINER_DATA_DIR} \
            -p ${HOST_PORT}:5432 \
            -it postgres $1

No comments: