1、拉取镜像文件docker pull postgres

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

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

  运行成功后默认数据库登录名、密码皆为postgres,当然也可以手动设置登录名、密码

  docker postgres使用

3、使用postgres客户端登录测试,这里使用的客户端是DataGrip

docker postgres使用

4、进入容器内部,使用postgres cli命令

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

  4.2 psql -U postgres -W 使用密码登录

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

docker postgres使用

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-17
  • 2021-11-25
  • 2021-08-26
  • 2022-12-23
  • 2021-07-27
  • 2022-03-11
猜你喜欢
  • 2022-12-23
  • 2021-04-29
  • 2021-05-22
  • 2023-03-15
  • 2021-09-19
  • 2022-12-23
  • 2021-07-02
相关资源
相似解决方案