一、确保docker安装完成
安装过程略。
二、获取镜像
1、查询镜像
docker search postgres

NAME --镜像名称
DESCRIPTION --镜像描述
STARS --标星数
OFFICIAL --官方的
圈红的地方为postgres官方镜像文件,建议使用官方镜像。
2、拉取镜像文件(因项目需要,这里拉取11.5版本)
docker pull postgres:11.5

查看已获取的镜像
docker images

我们看到postgres 11.5版本已拉取成功。
三、配置
配置命令:
docker run --name [容器名称] -e POSTGRES_PASSWORD=[密码] -p 5432:5432 -d postgres:11.5
如:
docker run --name Postgres11.5 -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:11.5
使用Navicat连接


Docker 官方文档:https://hub.docker.com/_/postgres