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