From PostgreSQL wiki

Jump to: navigation, search


PostgreSQL Testing Docker Images

The PostgreSQL Testing Docker Images are built so that you can test new versions of PostgreSQL without having to go through installation, configuration, and possibly clobbering your local installation of PostgreSQL in the process. They also allow you to do "destructive" testing because the instance you are running PostgreSQL on is temporary.

Here's some ideas on doing alpha/beta testing.


First, you need to have Docker installed.

Then install the image from the Docker Hub. See below for image names. On the command line, it's as simple as:

   docker run -it IMAGE_NAME
   docker run -it jberkus/postgres95-test

For Mac and Windows users, we recommend Kitematic, which gives an an easy graphical install.


We suggest mounting one or more volumes from your machine with things you can test in them. For example:

  docker run -it --volume "/home/user/postgres/tests:/tests" jberkus/postgres95-test:alpha

Note that the volumes command needs an absolute path; the one above is an example.

In Kitematic, you can add the volumes through the graphical interface.

Images Available

You can always grab the latest test image simply by installing jberkus/postgres95-test.


This is an interactive image, meaning that you'll be given a shell on the command line inside the image. It will shut down when you exit. It is also a very large image, because it includes quite a bit of stuff. It is built from the postgres-test-container project.

In order to get started, you'll want to run it interactively, then switch to the postgres user and start PostgreSQL:

   docker run -it jberkus/postgres95-test
   root@6cbace9fd9b4:/# su - postgres
   postgres@6cbace9fd9b4:~$ pg_ctl start
   server starting
   postgres@6cbace9fd9b4:~$ [ @  @ 2015-07-02 05:20:43.538 GMT]:LOG:  redirecting log output to logging collector process
   [ @  @ 2015-07-02 05:20:43.538 GMT]:HINT:  Future log output will appear in directory "pg_log".

This image includes PostgreSQL 9.5 compiled from source, with the following details:

  • installed to /usr/local/pgsql/
  • listening inside and outside the container on port 5432, both IPv4 and IPv6
  • requires no authentication inside the container, but outside requires the password "postgres" for the user postgres
  • replication is enabled, with the local instance running as a master
  • ssl is enabled
  • checksums on the data directory are on

This image includes the following extensions, so that you can test them with the new version and with each other:

The "pgxn" installer is also installed on the command line if you should want to install other extensions from PGXN. If you wanted to install plv8, for example, do this from the container shell as user "postgres:

   pgxn install plv8

The sample database "libdata" is also installed in case you want something to poke around at. This is owned by the "libdata" user, who has the password "books".

Testing Notes

In /usr/local/pgsql/data/postgresql.conf, you will see a simplified "postgresql.conf" file. This has some things worth testing in it:

  • new configuration settings are flagged with the comment #NEW SETTING. How about trying to change them?
  • several plugins which require shared libraries are commented out. You could uncomment those, restart and try them with the new version.

This image is also set up ready for replication. Try starting a 2nd container, rm the data directory, and do a pg_basebackup. Test various replication configurations. Try failing over, and with pg_rewind, failing back.

Personal tools