Skip to content

Instantly share code, notes, and snippets.

@abhisekp
Last active January 26, 2024 08:53
Show Gist options
  • Save abhisekp/e65d35d9ca444567bced75601548fc58 to your computer and use it in GitHub Desktop.
Save abhisekp/e65d35d9ca444567bced75601548fc58 to your computer and use it in GitHub Desktop.
Set up postgresql locally using docker

Postgresql DB

Add the following alias to .zshrc or .bashrc file.

alias psql="docker exec -it postgres psql -U abhisekp"
# Create a network
docker network create postgres-net
# Run postgres server
docker run --restart always \
-p 5432:5432 \
--net postgres-net \
--name postgres \
-e POSTGRES_PASSWORD=pass \
-e POSTGRES_USER="$(whoami)" \
--user "$(id -u):$(id -g)" \
-v /etc/passwd:/etc/passwd:ro \
-v /data/postgresql:/var/lib/postgresql/data \
-d postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment