惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
S
Secure Thoughts
S
Security @ Cisco Blogs
S
Security Affairs
Forbes - Security
Forbes - Security
W
WeLiveSecurity
H
Hacker News: Front Page
T
Threatpost
Google Online Security Blog
Google Online Security Blog
S
Schneier on Security
有赞技术团队
有赞技术团队
WordPress大学
WordPress大学
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - Franky
腾讯CDC
IT之家
IT之家
博客园 - 聂微东
L
LINUX DO - 最新话题
罗磊的独立博客
Hacker News - Newest:
Hacker News - Newest: "LLM"
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 三生石上(FineUI控件)
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
C
CERT Recently Published Vulnerability Notes
Know Your Adversary
Know Your Adversary
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园_首页
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Cisco Talos Blog
Cisco Talos Blog
S
SegmentFault 最新的问题
酷 壳 – CoolShell
酷 壳 – CoolShell
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
美团技术团队
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
AI
AI
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Jina AI
Jina AI
Help Net Security
Help Net Security
N
News | PayPal Newsroom
月光博客
月光博客
Spread Privacy
Spread Privacy
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
N
News and Events Feed by Topic

博客园 - SmilingEye

每天5分钟,用碎片时间搞定软考系统架构设计师600词 2025年9月Java后端招聘市场技术风向标:666份招聘数据深度解读 微信小程序PDF签名 DBLock 面试题:ReentrantLock 实现原理 docker 升级(软件包离线方式) tomcat设置https 使用fastjson时spring security oauth2获取token格式变化 springboot之cookie操作 使用sed将win换行符转linux与linux换行符转win linux修改权限后git pull出现冲突 JWT简介 jenkins之SSH Publishers连接windows Windows安装OpenSSH服务 jenkins从远程服务器下载 重写mybatis的字符串类型处理器 mybatis-sqlite日期类型对应关系 docker常用命令 java sqlite docker,sqlite出错
docker安装postgresql
SmilingEye · 2019-11-11 · via 博客园 - SmilingEye

1.在linux执行以下代码:

docker run -p 5432:5432 -v /home/docker/postgresql/data:/var/lib/postgresql/data -e POSTGRES_PASSWORD=postgres -e TZ=PRC -d --name=some-postgres postgres:11.5-alpine

-p端口映射

-v将数据存到宿主服务器

-e POSTGRES_PASSWORD 密码(默认用户名postgres)

-e TZ=PRC时区,中国

-d后台运行

--name容器名称

2.时区问题

如果在启动容器时不设置时区,默认为UTC,使用now()设置默认值的时候将有时间差。

select now();
show time zone;

在设置环境变量时,提示:

Warning: the Docker specific variables will only have an effect if you start the container with a data directory that is empty; any pre-existing database will be left untouched on container startup.

意思是:数据目录为空时,设置环境变量有效;数据目录不为空时,将使用数据目录设置的环境变量,将保持不变。

例如上面代码的宿主服务器/home/docker/postgresql/data就是数据目录。

3.参考

dockerhub安装说明

https://hub.docker.com/_/postgres?tab=description

使用非docker安装postgresql安装设置时区,对docker安装可以参考,例如:postgresql.conf配置在宿主服务器/home/docker/postgresql/data下,设置同样有效

https://blog.csdn.net/max1124/article/details/78410315

https://github.com/docker-library/postgres/issues/137#issuecomment-217064811

https://www.postgresql.org/docs/9.5/app-initdb.html