theanurin/devel.postgres-15
PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance
For development and testing purposes we need pre-setup Postgres server to automate development and auto-testing activity. The container has pre-defined empty database (with flag table to ensure non-production case) and two users.
tcp/5432 - Postgres listening endpoint/data - Hold Postgres'es data/dbseed - Files *.sql from the folder is executing at startup of a container
/dbseed/*.sql - execute in devdb database as postgres user/dbseed/<db_name>/*.sql - execute in <db_name> database as postgres userdevdb"public"."emptytestflag"postgres - superuser (no password)devadmin - owner of the database devdb (no password)devuser - regular user (no password)Start for development
shelldocker run --interactive --tty --rm --publish 5432:5432 theanurin/devel.postgres-15
Use connection strings (no password):
postgres://postgres@127.0.0.1:5432/postgres - to login as superuserpostgres://devadmin@127.0.0.1:5432/devdb - to login as devdb ownerpostgres://devuser@127.0.0.1:5432/devdb - to login as regular userIn this scenario your init SQL files are placed in ./init-sql directory and will be applied in alphabetical order.
dockerfileFROM theanurin/devel.postgres-15 AS postgres_builder COPY ./init-sql/ /.builder-postgres.d/ RUN chmod +x /.builder-postgres.sh RUN /usr/local/bin/docker-builder-postgres-15.sh FROM theanurin/devel.postgres-15 COPY --from=postgres_builder /build/ /
In this scenario your have to provide shell script /.builder-postgres.sh that will execute at build time. The script responsible for data generation.
shell#!/bin/sh # # sample of generate-data.sh # set -e DB_NAME="my-db" DB_OWNER="${DB_NAME}-owner" # Execute command via file using Redirecting Input redirections psql --dbname=postgres --username=postgres --set user="${DB_OWNER}" --file=<(echo 'CREATE USER :"user" WITH LOGIN;') # Execute command via Here Documents redirections psql --dbname=postgres --username=postgres --set db="${DB_NAME}" --set db_owner="${DB_OWNER}" <<-'EOSQL' CREATE DATABASE :"db" WITH OWNER = :"db_owner" ENCODING = 'UTF8' CONNECTION LIMIT = -1; EOSQL # Execute command via inline SQL psql --dbname="${DB_NAME}" --username="${DB_OWNER}" --command='CREATE TABLE "test" ("id" INTEGER NOT NULL);' echo "Wow, ${DB_NAME} was created successfully!"
dockerfileFROM theanurin/devel.postgres-15 AS build_stage COPY ./generate-data.sh /.builder-postgres.sh RUN /usr/local/bin/docker-builder-postgres-15.sh FROM theanurin/devel.postgres-15 COPY --from=build_stage /build/ /
shell# Run container docker run --detach --name pg_builder --publish 5432:5432 theanurin/devel.postgres-15 # Fill you data into Postgres ./my-data-script.sh postgres://postgres@127.0.0.1:5432/postgres # Stop container and make new image docker stop pg_builder docker commit pg_builder my_devel.postgres-15_with_data # Use image my_devel.postgres-15_with_data
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务