Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mohamedaboelmagd/efc44c24f83c7de30343c5b44e0578e8 to your computer and use it in GitHub Desktop.
Save mohamedaboelmagd/efc44c24f83c7de30343c5b44e0578e8 to your computer and use it in GitHub Desktop.
Running PostgreSQL via Docker
### This gist is a part of the NestJS Zero to Hero course on Udemy.
### https://www.udemy.com/course/nestjs-zero-to-hero/?referralCode=F672C0C701844DC91F4D
To run PostgreSQL on Docker, run the following in your Terminal:
docker run --name postgres-nest -p 5432:5432 -e POSTGRES_PASSWORD=postgres -d postgres
@mohamedaboelmagd
Copy link
Author

i tried running this but the container exits as soon as it starts
Error: Database is uninitialized and superuser password is not specified.

You must specify POSTGRES_PASSWORD to a non-empty value for the

superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".

You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all

connections without a password. This is not recommended.

See PostgreSQL documentation about "trust":

@mohamedaboelmagd
Copy link
Author

sudo lsof -i :5432
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
postgres 1937 postgres 5u IPv4 37521 0t0 TCP localhost:postgresql (LISTEN)
(base) mohamed@mohamed-hp-probook-450-g4:$ sudo kill -9 1937
(base) mohamed@mohamed-hp-probook-450-g4:
$ sudo lsof -i :5432

sudo docker start 1ca9bcdee5bd306095ceaa3343cfdccc26d655b99e668c601f00df0900aa88b2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment