pgdev is a standalone Docker-based development wrapper for PostgreSQL.
- builds a reusable Debian-based toolchain image
- bind-mounts a PostgreSQL checkout into the container at
/src - stores build artifacts and data in a Docker volume at
/workspace - runs configure, build, tests, and a foreground server from the chosen source tree
This keeps the dev tooling independent from the PostgreSQL repo while still building and running local changes.
pgdevis the host-side command you rundocker/Dockerfile.devbuilds the toolchain imagedocker/dev-entrypoint.shruns inside the container
First, add pgdev to $PATH.
Build the toolchain image once:
pgdev build-imageBuild a PostgreSQL checkout or local changes:
pgdev --source ~/repos/postgresql buildRun tests:
pgdev --source ~/repos/postgresql testEnable opt-in PostgreSQL test categories with PG_TEST_EXTRA or --test-extra:
pgdev --source ~/repos/postgresql --test-extra xid_wraparound test
PG_TEST_EXTRA="ssl ldap" pgdev --source ~/repos/postgresql test
PG_TEST_EXTRA="ssl" pgdev --source ~/repos/postgresql --test-extra "ldap xid_wraparound" testPull the Meson test logs onto the host:
pgdev --source ~/repos/postgresql testlogsSummarize failures and skips from an exported log:
pgdev --source ~/repos/postgresql logreport
pgdev logreport ~/Downloads/pgdev-logs/meson-logs/testlog.jsonStart the server:
pgdev --source ~/repos/postgresql serverConnect from another terminal:
pgdev --source ~/repos/postgresql psqlRun a command inside the running server container:
pgdev --source ~/repos/postgresql exec
pgdev --source ~/repos/postgresql exec psql -c 'select version()'-
Edit code in your PostgreSQL checkout.
-
Rebuild:
pgdev --source ~/repos/postgresql build -
Run tests if needed:
pgdev --source ~/repos/postgresql test
-
Start the rebuilt server:
pgdev --source ~/repos/postgresql server -
Connect:
pgdev --source ~/repos/postgresql psql
The running server does not hot-reload binaries. If you change code, stop the server, rebuild, and start it again.
Build or rebuild the image:
pgdev build-imageConfigure:
pgdev --source ~/repos/postgresql configureBuild:
pgdev --source ~/repos/postgresql buildBuild PostgreSQL HTML/man docs:
pgdev --source ~/repos/postgresql docs
pgdev --source ~/repos/postgresql docs html
pgdev --source ~/repos/postgresql docs manExport built docs to the host:
pgdev --source ~/repos/postgresql getdocs
pgdev --source ~/repos/postgresql getdocs ~/Downloads/pgdev-docsRun the default test set:
pgdev --source ~/repos/postgresql testAdd opt-in PostgreSQL test categories:
pgdev --source ~/repos/postgresql --test-extra xid_wraparound test
PG_TEST_EXTRA="ssl ldap" pgdev --source ~/repos/postgresql test
PG_TEST_EXTRA="ssl" pgdev --source ~/repos/postgresql --test-extra "ldap xid_wraparound" testExport the Meson log directory, including testlog.txt and testlog.json:
pgdev --source ~/repos/postgresql testlogs
pgdev --source ~/repos/postgresql testlogs ~/Downloads/pgdev-logsSummarize failures and skips from testlog.json:
pgdev --source ~/repos/postgresql logreport
pgdev logreport ~/Downloads/pgdev-logs/meson-logs/testlog.jsonRun a suite or specific tests:
pgdev --source ~/repos/postgresql test --suite recovery
pgdev --source ~/repos/postgresql test recovery/017_shm
pgdev --source ~/repos/postgresql test recovery/017_shm recovery/018_wal_optimizeRun tests against a manually started server:
pgdev --source ~/repos/postgresql runningcheckOpen a shell:
pgdev --source ~/repos/postgresql shellOpen psql with defaults for this workflow:
pgdev --source ~/repos/postgresql psql
pgdev --source ~/repos/postgresql --port 55433 psql
pgdev --source ~/repos/postgresql psql -c 'select version()'pgdev psql uses the matching psql from the running server container's
temporary install, so the client major version tracks the checked-out
PostgreSQL branch instead of the host's psql.
Run a command inside the running server container:
pgdev --source ~/repos/postgresql exec
pgdev --source ~/repos/postgresql exec bash -lc 'psql -c "select version()"'Start the server on a different port:
pgdev --source ~/repos/postgresql --port 55433 serverRemove the build/data volume for a checkout:
pgdev --source ~/repos/postgresql cleanpgdev is designed for this use case.
By default, the workspace volume name is derived from the absolute source path, so different checkouts get different persistent build and data state.
If you run pgdev from inside a PostgreSQL checkout or git worktree, that
current directory is used automatically. PGDEV_BASE is only a fallback when
you are not already standing in a PostgreSQL source tree.
Examples:
pgdev --source ~/repos/postgresql-master build
pgdev --source ~/repos/postgresql-master serverpgdev --source ~/repos/postgresql-v18 build
pgdev --source ~/repos/postgresql-v18 --port 55433 serverThat lets you jump between versions without clobbering each checkout's build tree or cluster.
If you want to override the volume identity manually, use --workspace-key:
pgdev --source ~/repos/postgresql --workspace-key rel18 build
pgdev --source ~/repos/postgresql --workspace-key rel18 serverGlobal options:
--source PATHselects the PostgreSQL checkout--workspace-key KEYoverrides the derived workspace identity--port PORTchanges the forwarded port--shm-size SIZEsets the Docker/dev/shmsize used by the container--build-jobs NoverridesPG_BUILD_JOBSinside the container--test-jobs NoverridesPG_TEST_JOBSinside the container--test-extra LISTadds categories toPG_TEST_EXTRA--image NAMEchanges the Docker image name
Environment variables:
PGDEV_BASEPG_DEV_WORKSPACE_KEYPG_DEV_PORTPG_DEV_SHM_SIZEPG_DEV_BUILD_JOBSPG_DEV_TEST_JOBSPG_TEST_EXTRAPG_DEV_IMAGEPG_DEV_VOLUME
PG_DEV_VOLUME overrides the computed Docker volume name directly.
If both PG_TEST_EXTRA and --test-extra are provided, the combined set is
passed to the container with duplicates removed.
PGDEV_BASE can be used as the default source checkout path when --source is
omitted and the current directory is not already a PostgreSQL checkout.
- The source checkout is mounted read-only for most commands.
pgdev testandpgdev runningcheckmount the source checkout writable because some PostgreSQL tests generate temporary files alongside source fixtures.- The container defaults to
--shm-size=1g, and you can raise or lower that with--shm-sizeorPG_DEV_SHM_SIZE. - Build artifacts live in a Docker volume, not in a local repo.
pgdevfilters its Meson-D...options against the checked-out source tree's supported option set, so older PostgreSQL branches can reuse the same wrapper image.- The default database superuser in this workflow is
postgres. pgdev psqldefaults toPGUSER=postgresandPGDATABASE=postgres.pgdev execandpgdev psqltarget the runningpgdev servercontainer for the current workspace.pgdev docsbuilds documentation under/workspace/build/doc/src/sgmlin the Docker volume.pgdev getdocsexports/workspace/build/doc/src/sgmlto./pgdev-docs/<workspace-key>/sgmlby default.pgdev testlogsexports/workspace/build/meson-logsto./pgdev-logs/<workspace-key>/meson-logsby default.pgdev logreportreadstestlog.jsonand prints failures and skip reasons. With--source, it defaults to./pgdev-logs/<workspace-key>/meson-logs/testlog.json.- Host TCP access is configured for this dev environment, and the port is
published only on
127.0.0.1on the host.