On the 2cnd of July the PostgreSQL Global Development Group released an alpha version of the upcoming PostgreSQL 9.5. The same day, Josh Berkus, another of those PostgreSQL core team members released a docker image for testing this alpha release. It’s never been that easy to get started with PostgreSQL or testing new features.
If you are on Linux the docker packages should be available for your distribution. For Oracle Linux 7.1 make sure that the addons yum repository is enabled
cat /etc/yum.repos.d/public-yum-ol7.repo | grep -A 3 addon [ol7_addons] name=Oracle Linux $releasever Add ons ($basearch) baseurl=http://public-yum.oracle.com/repo/OracleLinux/OL7/addons/$basearch/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
Installing docker is just:
yum install -y docker systemctl start docker.service
Once docker is running we can search the docker registry:
docker search postgres NAME DESCRIPTION STARS OFFICIAL AUTOMATED postgres The PostgreSQL object-relational database ... 809 [OK] abevoelker/postgres Postgres 9.3 + WAL-E + PL/V8 and PL/Python... 7 [OK] linuxkonsult/postgres A Postgres trusted build installed with Chef. 5 [OK] macadmins/postgres Postgres that accepts remote connections b... 5 [OK] jamesbrink/postgres Highly configurable PostgreSQL container. 2 [OK] kampka/postgres A postgresql image build on top of an arch... 2 [OK] azukiapp/postgres Docker image to run PostgreSQL by Azuki - ... 2 [OK] clkao/postgres-plv8 Docker image for running PLV8 1.4 on Postg... 1 [OK] eeacms/postgres Docker image for PostgreSQL (RelStorage re... 0 [OK] bantl23/postgres postgres development 0 [OK]
Get the PostgreSQL 9.5 alpha container and run it:
mkdir -p /var/tmp/docker/postgres docker run -it --volume "/var/tmp/docker/postgres:/tests" jberkus/postgres95-test:alpha Unable to find image 'jberkus/postgres95-test:alpha' locally alpha: Pulling from jberkus/postgres95-test 39bb80489af7: Pull complete df2a0347c9d0: Pull complete 65c152b01d5d: Pull complete 22e16a33eefa: Pull complete b7003ab928a5: Pull complete b9ad663e6550: Pull complete 712b208afbdf: Pull complete 6db70337094f: Pull complete 94dc52568254: Pull complete af3497b0915c: Pull complete 203e588497fa: Pull complete 35133c09fcd4: Already exists Digest: sha256:cd722ecdcfb68467d077f1edddf9cfcf1faabb954f544098a854bd8d83b61871 Status: Downloaded newer image for jberkus/postgres95-test:alpha
Looks good so we should be able to use it:
root@5e74f2e32422:/# su - postgres postgres@5e74f2e32422:~$ pg_ctl start server starting postgres@5e74f2e32422:~$ [ @ @ 2015-07-03 06:57:09.840 GMT]:LOG: redirecting log output to logging collector process [ @ @ 2015-07-03 06:57:09.840 GMT]:HINT: Future log output will appear in directory "pg_log". postgres@5e74f2e32422:~$ psql psql (9.5alpha1) Type "help" for help. postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+---------+-------+----------------------- libdata | libdata | UTF8 | C | C | postgres | postgres | UTF8 | C | C | template0 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | C | C | =c/postgres + | | | | | postgres=CTc/postgres (4 rows)
Cool. Minimal effort to get a test infrastructure with docker. (Please notice that I did everything as root. It is always better to setup proper sudo permissions)