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 | |