当前位置: 首页 > news >正文

利用Docker安装PostgreSQL 19 dev版

PostgreSQL官方只提供了正式版的镜像,想要试用dev版,又不想自己编译。结果在下面这个网站找到了一个,
https://github.com/ryanbooz/bluebox-docker
它不是纯净的官方版本,自带了一些初始化脚本,正好用来试验。

  1. 拉取镜像
sudo docker pull ghcr.io/ryanbooz/bluebox-postgres:19-dev [sudo] kylin 的密码: 19-dev: Pulling from ryanbooz/bluebox-postgres d3d5d8ab26d2: Pull complete c389a2748e7f: Pull complete c8129a85d9e1: Pull complete 7f4f950f4a59: Pull complete d1e0edeeb42f: Pull complete e58d32278daa: Pull complete d5876f284dbc: Pull complete f01cc50a7497: Pull complete 4f4fb700ef54: Pull complete Digest: sha256:253d42b69d62692f3aa82a976702e4ff389092025ad9ceb2a58b5f6089d15378 Status: Downloaded newer image for ghcr.io/ryanbooz/bluebox-postgres:19-dev sudo docker image list -a|grep blue ghcr.io/ryanbooz/bluebox-postgres 19-dev a37dec750520 6 days ago 595MB

2.运行容器,注意如果宿主机上有postgres服务正在运行, 不要用-p 5432:5432参数,否则报错,下面用–net=host参数。

sudo docker run --name pg19dev -e POSTGRES_PASSWORD=password -e POSTGRES_DB=mydb -v /shujv/par:/par --net=host a37dec750520 Initializing PostgreSQL database... The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are enabled. fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default "max_connections" ... 100 selecting default "shared_buffers" ... 128MB selecting default time zone ... Etc/UTC creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok Success. You can now start the database server using: pg_ctl -D /var/lib/postgresql/data -l logfile start waiting for server to start....2026-02-13 00:11:15.207 UTC [37] LOG: starting PostgreSQL 19devel on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit 2026-02-13 00:11:15.219 UTC [37] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2026-02-13 00:11:15.256 UTC [43] LOG: database system was shut down at 2026-02-13 00:11:14 UTC 2026-02-13 00:11:15.269 UTC [37] LOG: database system is ready to accept connections done server started Running /docker-entrypoint-initdb.d/01-create-roles-and-database.sql .... PostgreSQL initialization complete. 2026-02-13 00:15:17.152 UTC [1] LOG: starting PostgreSQL 19devel on aarch64-unknown-linux-gnu, compiled by gcc (Debian 12.2.0-14+deb12u1) 12.2.0, 64-bit 2026-02-13 00:15:17.152 UTC [1] LOG: could not bind IPv4 address "0.0.0.0": Address already in use 2026-02-13 00:15:17.152 UTC [1] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 2026-02-13 00:15:17.152 UTC [1] LOG: listening on IPv6 address "::", port 5432 2026-02-13 00:15:17.174 UTC [1] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2026-02-13 00:15:17.202 UTC [104] LOG: database system was shut down at 2026-02-13 00:15:16 UTC 2026-02-13 00:15:17.216 UTC [1] LOG: database system is ready to accept connections 2026-02-13 00:15:17.237 UTC [107] LOG: pg_cron scheduler started

初始化脚本的输出很长,截断了。
3.服务端在前台显示,如果想要切换到后台,可用^C中断,然后重新启动服务。

2026-02-13 00:17:08.473 UTC [1] LOG: received fast shutdown request 2026-02-13 00:17:08.484 UTC [1] LOG: aborting any active transactions 2026-02-13 00:17:08.484 UTC [107] LOG: pg_cron scheduler shutting down 2026-02-13 00:17:08.485 UTC [1] LOG: background worker "logical replication launcher" (PID 108) exited with exit code 1 2026-02-13 00:17:08.485 UTC [1] LOG: background worker "pg_cron launcher" (PID 107) exited with exit code 1 2026-02-13 00:17:08.486 UTC [102] LOG: shutting down 2026-02-13 00:17:08.496 UTC [102] LOG: checkpoint starting: shutdown fast 2026-02-13 00:17:08.688 UTC [102] LOG: checkpoint complete: wrote 18 buffers (0.1%), wrote 3 SLRU buffers; 0 WAL file(s) added, 6 removed, 0 recycled; write=0.024 s, sync=0.039 s, total=0.203 s; sync files=17, longest=0.011 s, average=0.003 s; distance=106191 kB, estimate=106191 kB; lsn=0/AAA133C8, redo lsn=0/AAA133C8 2026-02-13 00:17:08.747 UTC [1] LOG: database system is shut down sudo docker start pg19dev pg19dev

4.就可以用docker exec -it登录容器执行操作了。

sudo docker exec -it pg19dev psql -U bb_admin -d bluebox psql (19devel) Type "help" for help. bluebox=> bluebox=> -- Current status SELECT (SELECT count(*) FROM bluebox.rental WHERE upper(rental_period) IS NULL) as open_rentals, (SELECT count(*) FROM bluebox.customer WHERE activebool) as active_customers, (SELECT count(*) FROM bluebox.inventory WHERE status_id = 1) as inventory_available; open_rentals | active_customers | inventory_available --------------+------------------+--------------------- 1843 | 174980 | 1462726 (1 row) bluebox=> -- Daily rental volume SELECT lower(rental_period)::date as day, count(*) as rentals, sum(p.amount) as revenue FROM bluebox.rental r JOIN bluebox.payment p USING (rental_id) WHERE lower(rental_period) > now() - interval '7 days' GROUP BY 1 ORDER BY 1; day | rentals | revenue -----+---------+--------- (0 rows) bluebox=> -- Top rented films SELECT f.title, count(*) as rentals FROM bluebox.rental r JOIN bluebox.inventory i USING (inventory_id) JOIN bluebox.film f USING (film_id) WHERE lower(rental_period) > now() - interval '30 days' GROUP BY f.film_id, f.title ORDER BY rentals DESC LIMIT 10; title | rentals -----------------------------------------------+--------- Haunted Mansion | 164 Elemental | 162 Gran Turismo | 153 Fast X | 149 Meg 2: The Trench | 145 Blue Beetle | 142 Sound of Freedom | 142 Megamind vs. the Doom Syndicate | 140 Transformers: Rise of the Beasts | 139 Mission: Impossible - Dead Reckoning Part One | 138 (10 rows) bluebox=> -- Customer churn analysis SELECT date_trunc('month', status_date) as month, count(*) FILTER (WHERE reason_code = 'inactivity') as churned, count(*) FILTER (WHERE reason_code = 'winback') as reactivated FROM bluebox.customer_status_log WHERE reason_code IN ('inactivity', 'winback') GROUP BY 1 ORDER BY 1; month | churned | reactivated ------------------------+---------+------------- 2026-02-01 00:00:00+00 | 3071 | 60 (1 row)

试验了上述网站的几个测试SQL,还测试了一个复现postgres 18.1的bug的SQL,结果显示,bug已被修复。

bluebox=> with cte as (select array[g, 2] as a from generate_series(1, 3) g) select a[2], a[(select a[2])] from cte; a | a ---+--- 2 | 2 2 | 2 2 | 2 (3 rows) bluebox=> with cte as (select array[g, 2] as a from generate_series(1, 3) g)select * from cte; a ------- {1,2} {2,2} {3,2} (3 rows)

以前在同一台机器上拉取官方18.1镜像,docker run不能启动,这个镜像反而能顺利使用,不明所以。

http://www.jsqmd.com/news/379129/

相关文章:

  • AI原生应用领域可解释性的发展瓶颈与对策
  • 案例详述:基于灵易Smart-SIM智能快速预测工具的电动海水泵浮阀隔振装置阀架结构快速设计
  • 教育平台PHP如何实现视频大文件的多线程分块上传?
  • 基于openssl的sm4加密,加密数据,验证OK深度解析:原理、实战与踩坑记录
  • AI专著生成工具大揭秘!从构思到完稿,全程助力专著撰写
  • 低查重AI教材生成工具,快速产出高质量教材,AI写教材不再难!
  • 2026 上海靠谱装修公司口碑推荐 腾阁装饰全区域安心交付之选 - 品牌智鉴榜
  • 低查重方案大公开:AI教材写作实用技巧与优质工具盘点
  • 2026国内最新双组份中空玻璃胶品牌top5推荐!服务深度覆盖江苏、山东、济南等地,优质厂商权威榜单发布,合规品质双优助力工程建设 - 品牌推荐2026
  • Spring 框架如何整合Redis缓存中间件? - 指南
  • 低查重AI教材生成秘籍,专业工具为你的教材编写保驾护航
  • 实用指南:GraphRAG:让大模型在知识图谱中精准导航
  • 深度解析 Firefox 144+ 编译架构(五)深入解析 Bootstrap 引导模式 - 详解
  • AI教材编写新突破!低查重AI教材写作工具,大幅提升创作效率!
  • 掌握AI专著生成技巧,借助工具轻松完成百万字专著创作
  • 中石化加油卡回收时机分析 - 京顺回收
  • TikTok视频下载技术揭秘:开发者如何高效获取跨平台内容
  • 洛谷 - P5094 [USACO04OPEN] MooFest G 加强版 题解
  • 医疗设备产品设计如何创新?2026三大趋势解析+设计策略指南 - 匠言榜单
  • 逆向工程视角:揭秘 TikTok 视频去水印解析的底层逻辑与实现
  • 2026国内最新喷胶企业top5推荐!服务深度覆盖江苏、山东、济南等地,优质喷胶品牌权威榜单发布,多场景适配助力高效粘接 - 品牌推荐2026
  • AI专著撰写不用愁,热门工具解析帮你轻松搞定学术大作
  • 基于深度学习YOLOv12的裂缝识别检测系统(YOLOv12+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)
  • 轻量高效!TikTok无水印视频下载工具实战,附服务端解析思路与代码
  • 掌握AI专著写作诀窍,使用工具轻松搞定长篇学术专著
  • 基于深度学习YOLOv11的裂缝识别检测系统(YOLOv11+YOLO数据集+UI界面+登录注册界面+Python项目源码+模型)
  • Ubuntu 22.04 安装 K8S 1.28.2版本
  • 小容量32单片机也上bootloader?拆机烧录的苦谁懂,能上抓紧上
  • 用AI专著写作工具就对了!流程全解析,轻松搞定百万字巨著
  • WPS数据写入Word模版文档,批量生成文档 - 实践