下载镜像
docker pull postgrest/postgrest
正确运行需要修改postgrest配置文件。可以修改镜像中的配置文件/etc/postgrest.conf,或者修改运行的环境变量(具有“ PGRST_ ”前缀)。使用下面命令可以查看系统的环境变量:
docker inspect -f "{{.Config.Env}}" postgrest/postgrest
最简单的postgrest配置文件如下
# 连接URI
db-uri = "postgres://user:[email protected]:5432/database"
# database schema to expose to REST clients
db-schema = "public"
# 如果客户端没有认证,使用的数据库角色
db-anon-role = "user"
运行docker
docker run --rm -p 3000:3000 \
-e PGRST_DB_URI="postgres://user:[email protected]/database" \
-e PGRST_DB_ANON_ROLE="user" \
-e PGRST_DB_SCHEMA="public" \
postgrest/postgrest
访问 http://ip:3000即可看到结果。
为了方便测试,安装一个swagger。