
PostGraphile是一款将PostgreSQL数据库与GraphQL技术结合的工具,能够自动生成高性能GraphQL API。本Docker镜像基于PostGraphile V4版本(稳定但功能冻结),V5 beta版本已接近完成,具备更多新特性(如Grafast引擎、更低Postgres负载、真多态性等)。PostGraphile通过自动检测数据库表、列、索引、关系、视图、函数等结构,快速构建智能且可扩展的GraphQL服务,无需手动编写API层代码,大幅提升开发效率。
--watch模式,自动检测数据库模式变化并热重载,无需重启服务。--watch模式实时同步数据库变化;生产环境中作为稳定、高性能的API服务运行。bashdocker pull graphile/postgraphile
bashdocker run --init graphile/postgraphile --help
1. 连接本地PostgreSQL并暴露API端口
bashdocker run --init -p 5000:5000 graphile/postgraphile \ --connection postgres://POSTGRES_USER:POSTGRES_PASSWORD@POSTGRES_HOST:POSTGRES_PORT/POSTGRES_DATABASE \ --schema app_public \ --watch
参数说明:
-p 5000:5000:将容器内5000端口映射到主机5000端口(API服务端口)--connection:PostgreSQL连接字符串,格式为postgres://用户:密码@主机:端口/数据库名--schema:指定要暴露的数据库schema(如app_public)--watch:启用监听模式,自动检测数据库模式变化并热重载2. macOS用户避免端口冲突(AirPlay占用5000端口)
bashdocker run --init -p 4000:4000 graphile/postgraphile \ --connection postgres://user:pass@host:5432/db \ --schema public \ --port 4000
说明:通过--port指定容器内端口为4000,主机端口映射为4000,避免与macOS AirPlay服务冲突。
3. 生产环境基本配置(禁用GraphiQL,指定JWT密钥)
bashdocker run --init -d -p 8080:8080 --name postgraphile-service graphile/postgraphile \ --connection postgres://prod_user:prod_pass@prod-postgres:5432/prod_db \ --schema app_public \ --port 8080 \ --disable-graphiql \ --jwt-secret YOUR_JWT_SECRET \ --default-role app_anonymous
参数说明:
-d:后台运行容器--name:指定容器名称--disable-graphiql:生产环境禁用GraphiQL界面--jwt-secret:配置JWT认证密钥--default-role:设置默认数据库角色| 参数 | 说明 | 示例 |
|---|---|---|
--connection | PostgreSQL连接字符串(必填) | postgres://user:pass@host:5432/db |
--schema | 指定数据库schema(可多个,逗号分隔) | app_public,app_private |
--port | 服务监听端口(容器内) | 4000 |
--watch | 监听数据库模式变化,自动重载 | - |
--graphiql | 启用GraphiQL界面(默认启用,开发环境推荐) | - |
--disable-graphiql | 禁用GraphiQL界面(生产环境推荐) | - |
--jwt-secret | JWT认证密钥,用于验证JWT令牌 | your-256-bit-secret |
--default-role | 未认证用户的默认数据库角色 | app_anonymous |
--classic-ids | 使用Relay风格的id代替默认nodeId | - |
--append-plugins | 添加自定义插件(需容器内安装) | @graphile-contrib/pg-simplify-inflector |
--port指定其他端口(如4000、8080)。--network指定Docker网络,或使用主机网络模式(--net=host)。您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务