Postgres on Docker
docker pull postgres
Using default tag: latest
latest: Pulling from library/postgres
a9eb63951c1c: Pull complete
b192c7f382df: Pull complete
e7ce3f587986: Pull complete
4098744a1414: Pull complete
4c98d6f3399d: Pull complete
65e57fefc38a: Pull complete
d61d9528cfd5: Pull complete
de6b20f44659: Pull complete
25db13ff0bef: Pull complete
7f74f4b0e936: Pull complete
144c847b11fb: Pull complete
cf0afd1be009: Pull complete
fe0c14991327: Pull complete
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest 83ce63c594ee 5 days ago 355MB
docker run --name test -e POSTGRES_PASSWORD=Test@123 -d postgres
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS
83ec4a222 postgres "docker-entrypoint.s…" 2 minutes ago Up
docker exec -it 83ec4a222 bash
root@83ec4a222:/#
psql -h localhost -p 5432 -U postgres -w
psql (14.0 (Debian 14.0-1.pgdg110+1))
Type "help" for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=#
postgres=# select current_database();
current_database
------------------
postgres
(1 row)
postgres=# select datname from pg_catalog.pg_database;
datname
-----------
postgres
template1
template0
(3 rows)
postgres=# select table_name from information_schema.tables limit 10;
table_name
-----------------------
pg_statistic
pg_type
pg_foreign_table
pg_authid
pg_shadow
pg_statistic_ext_data
pg_roles
pg_settings
pg_file_settings
pg_hba_file_rules
(10 rows)
No comments:
Post a Comment