-
Notifications
You must be signed in to change notification settings - Fork 43
[Docker] Access the PostgreSQL command line terminal through Docker
Radu Raicea edited this page Sep 30, 2017
·
1 revision
If you need to access the PostgreSQL database command line terminal, you need to go inside the postgres
Docker container. There, you can run SQL command and edit the database.
To enter the postgres container, the application must be running
docker-compose up --build
Once the application is running, open a new Docker terminal or the equivalent, and run the following command
docker exec -it postgres psql -U postgres
This command runs the psql
command (which is the command line for PostgreSQL) under the user postgres
.
PostgreSQL can have multiple databases inside of it. In order to connect to one, you need to run the following command
\c <database_name>
To check all the tables that exist inside a database, run
\d
To check the details of a particular table, run
\d+ <table_name>
To exit the container, run the following command
\q