下载PostgreSQL镜像:
docker pull postgres:12.4
启动:
docker run --name postgres \
--restart=always \
-e POSTGRES_PASSWORD=123456 \
-p 5432:5432 \
-v /data/postgresql:/var/lib/postgresql/data \
-d postgres:12.4
查看PostgreSQL容器:
docker ps | grep postgres
033d9ff7b5c6 postgres:12.4 "docker-entrypoint.s…" 3 days ago Up 3 days 0.0.0.0:5432->5432/tcp postgres
进入容器:
docker exec -it 033d9ff7b5c6 /bin/bash
使用国内镜像
cat <<EOF > /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian/ buster main
deb-src http://mirrors.ustc.edu.cn/debian/ buster main
deb http://security.debian.org/debian-security buster/updates main
deb-src http://security.debian.org/debian-security buster/updates main
# buster-updates, previously known as 'volatile'
deb http://mirrors.ustc.edu.cn/debian/ buster-updates main
deb-src http://mirrors.ustc.edu.cn/debian/ buster-updates main
deb http://mirrors.ustc.edu.cn/debian/ buster-backports main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ buster-backports main non-free contrib
EOF
更新apt-get命令
apt-get update
安装yum命令
apt-get install vim
apt-get install yum
apt-get install wget
创建目录
mkdir /etc/yum.repos.d/
下载源配置文件
#创建目录#
mkdir /etc/yum.repos.d/
#epel源#
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
生成缓存
yum clean all
yum makecache
apt install libgdal20
apt-get install postgresql-12-postgis-3 postgresql-12-postgis-3-dbgsym postgresql-12-postgis-3-scripts
在postgresql客户端执行
DROP EXTENSION postgis;
SET search_path to public;
CREATE EXTENSION postgis;