docker postgres使用


1、拉取鏡像文件docker pull postgres

2、容器后台進程運行,向外暴露5432端口

  docker run --name mypostgres -e POSTGRES_PASSWORD=postgres -d -p 5432:5432 postgres

  運行成功后默認數據庫登錄名、密碼皆為postgres,當然也可以手動設置登錄名、密碼

  

3、使用postgres客戶端登錄測試,這里使用的客戶端是DataGrip

4、進入容器內部,使用postgres cli命令

  4.1 默認起手式 docker exec -it [mypostgres] /bin/bash

  4.2 psql -U postgres -W 使用密碼登錄

  4.3 使用psql --help可查看所有cli命令

附上psql cli命令文檔:https://postgrescheatsheet.com/#/databases


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM