跳转到主要内容

omni_containers

Omnigres Docker容器管理模块

omnigres · Omnigres Docker容器管理模块

概览

ID扩展软件包版本类别许可证编程语言
2944omni_containersomnigres0.2.0FEATApache-2.0C
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d--否是否是否否

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY0.2.019 18 17 16 15omnigresomni_httpc, omni_web
RPMPIGSTY2026021219 18 17 16 15omnigres_$vpostgresql$v-contrib, postgresql$v-plpython3, python3-pip
DEBPIGSTY2026021219 18 17 16 15postgresql-$v-omnigrespostgresql-plpython3-$v, python3-pip
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el8.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el9.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
el10.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d12.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
d13.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u22.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u24.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.x86_64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212
u26.aarch64N/APIGSTY 20260212PIGSTY 20260212PIGSTY 20260212PIGSTY 20260212

源码

pig build pkg omnigres;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install omnigres;		# install by package name
pig install omni_containers;		# install by extension name

pig install omni_containers -v 18;   # install for PG 18
pig install omni_containers -v 17;   # install for PG 17
pig install omni_containers -v 16;   # install for PG 16
pig install omni_containers -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION omni_containers CASCADE; -- requires omni_httpc, omni_web

用法

omni_containers: Docker 容器管理

omni_containers 扩展从 PostgreSQL 管理 Docker 容器生命周期。需要 Docker Engine API 访问权限(默认 unix:///var/run/docker.sock)。

创建并启动容器

SELECT * FROM omni_containers.docker_container_create(
    'busybox',
    cmd  => 'echo Hello world',
    pull => true
);

参数:image(必需)、cmd、attach(默认 db.omni)、start(默认 true)、wait(默认 false)、pull(默认 false)、options(jsonb)。

容器日志

SELECT * FROM omni_containers.docker_container_logs('container_id');

支持 stdout、stderr、since、until、timestamps、tail 参数。

在容器中执行命令

SELECT * FROM omni_containers.docker_container_exec('container_id', 'ls -la');

停止和检查

SELECT * FROM omni_containers.docker_container_stop('container_id');
SELECT info->'State'->'ExitCode' FROM omni_containers.docker_container_inspect('container_id') AS info;

列出 Docker 镜像

SELECT repo_tags FROM omni_containers.docker_images;

完整工作流示例

WITH container AS (
    SELECT * FROM omni_containers.docker_container_create(
        'ghcr.io/yrashk/psql',
        cmd  => $$psql -c 'create table test ();'$$,
        wait => true, pull => true) AS id
)
SELECT
    omni_containers.docker_container_inspect(id)->'State'->'ExitCode' AS exit_code,
    omni_containers.docker_container_logs(id) AS logs
FROM container;

表格阅读器