PostgreSQL & PgAdmin using Docker + Postgres Commands
Gavin Dang
Posted on April 1, 2024
Ref: https://migueldoctor.medium.com/how-to-run-postgresql-pgadmin-in-3-steps-using-docker-d6fe06e47ca1
Step1:
Download postgres docker image
$ docker pull postgres:latest
Step2:
Download pgadmin4
$ docker pull dpage/pgadmin4:latest
$ docker run -p 5050:80 -e 'PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org' -e 'PGADMIN_DEFAULT_PASSWORD=admin' -d --name pgadmin4 dpage/pgadmin4
Step3:
Setup pgadmin 4
Open pgAdmin4 in your browser at: http://localhost:5050
Log in:
Username: pgadmin4@pgadmin.org
Password: admin
Click Add New Server and fill in the following fields:
Server Name: pg (or whatever you prefer)
On the Connection tab:
Host: host.docker.internal
Port: 49153
Username: postgres
Password: postgrespw
Postgres Commands
sudo service postgresql start
sudo -u postgres psql
list of relations
postgres=# \dt
list of databases
postgres=# \l
Connect to specific database
postgres=# \c "database name"
List info in a table
databaseName=# \d user
show data in a table
TABLE "tableNamehere";
Posted on April 1, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024