The following packages will be upgraded:
postgresql-9.6 postgresql-contrib-9.6
Most likely the new postgresql package overwrites the changes we do in the Dockerfile. It should be solved by pulling the latest postgres:9.6
image.
@yosifkit what do you mean by this?
It should be solved by pulling the latest postgres:9.6 image.
I just tried to do the same and it's still updating the packages, restoring the standard postgresql.conf.sample, effectively restoring listen_addr to default (i.e. localhost). What is the recommended way to install plpython in Docker?
@hraban, if you are having the same issue, it means that the image on your system has an outdated postgres package. It happens when the postgres-9.6
package gets updated in the upstream apt repository and then when you go to install plpython
it has a dependency on the newer package in apt so it gets pulled in.
I just tested it with the latest 9.6
image and it works fine, which is currently PG_VERSION=9.6.2-1.pgdg80+1
.
I was also affected by this problem.
This problem is caused by installation of PostgreSQL packages from upstream by apt-get, but only during the build phase. If you upgrade postgresql-plpython and postgresql packages later, you should be cool. But this pretty much kills the whole idea of having docker image.
@pensnarik , please watch what happens when you apt-get install postgresql-plpython. This command will probably try to upgrade packages from the base image using apt. This, in turn, will cause connection problems you described. When will it happen? When Debian's repo has newer versions
At the moment of this writing, PostgreSQL image from docker library has version 9.6.5. Debian upstream has version 9.6.6. No wonder this bug will happened kind of randomly. To my surprise, for me, suddenly continuous integration started to break - in a place that I have not touched at all.
I am working on my solution but it looks like it more and more skews in the "build your own fat image" direction. Which, again, pretty much kills the whole idea of containers for my development.
The other solution would be to upgrade official images to 9.6.6 but I am sure this issue will re-appear some time later.
docker-library devs, please keep this open if you don't mind.
Another solutions:
pinning in-image versions so apt-get won't upgrade them.
Here's my experience, @ivan-kolmychek , unless you meant something else.
There's no 9.6.5 package for postgresql-plpython in pgdg.
[mpasternak:~]$ docker run --rm -it postgres:9.6 /bin/bash
root@700e9cc4aff3:/# psql --version
psql (PostgreSQL) 9.6.5
root@700e9cc4aff3:/# dpkg -l postgresql-9.6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-=============-=============-======================================
ii postgresql-9.6 9.6.5-1.pgdg8 amd64 object-relational SQL database, versio
root@700e9cc4aff3:/# apt-get update; apt-get install postgresql-plpython-9.6=9.6.5-1.pgdg8
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://apt.postgresql.org jessie-pgdg InRelease [56.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:3 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [612 kB]
Get:5 http://deb.debian.org jessie Release.gpg [2,373 B]
Get:6 http://deb.debian.org jessie Release [148 kB]
Get:7 http://apt.postgresql.org jessie-pgdg/main amd64 Packages [141 kB]
Get:8 http://apt.postgresql.org jessie-pgdg/9.6 amd64 Packages [1,699 B]
Get:9 http://deb.debian.org jessie-updates/main amd64 Packages [23.2 kB]
Get:10 http://deb.debian.org jessie/main amd64 Packages [9,063 kB]
Fetched 10.3 MB in 8s (1,236 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '9.6.5-1.pgdg8' for 'postgresql-plpython-9.6' was not found
root@700e9cc4aff3:/# apt-get install postgresql-plpython-9.6=9.6.5-1
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '9.6.5-1' for 'postgresql-plpython-9.6' was not found
root@700e9cc4aff3:/# apt-get install postgresql-plpython-9.6=9.6.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '9.6.5' for 'postgresql-plpython-9.6' was not found
root@700e9cc4aff3:/# apt-get install postgresql-plpython-9.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libpython2.7 postgresql-9.6 postgresql-contrib-9.6
Suggested packages:
locales-all libdbd-pg-perl
The following NEW packages will be installed:
libpython2.7 postgresql-plpython-9.6
The following packages will be upgraded:
postgresql-9.6 postgresql-contrib-9.6
2 upgraded, 2 newly installed, 0 to remove and 6 not upgraded.
Need to get 5,823 kB of archives.
After this operation, 5,973 kB of additional disk space will be used.
Do you want to continue? [Y/n]
@mpasternak yep, it seems that pgdg does not keep old versions of packets - check out https://apt.postgresql.org/pub/repos/apt/pool/9.6/p/postgresql-9.6/ for the list, it has only 9.6.6 at this moment.
But docker-library/postgres has already moved to 9.6.6 (82e8101) so try to run docker pull postgres:9.6
first.
After I pulled the new image, it works for me:
[ivanko] ~
$ docker run --rm -it postgres:9.6 /bin/bash
root@7be85c8651ab:/# psql --version
psql (PostgreSQL) 9.6.6
root@7be85c8651ab:/# dpkg -l postgresql-9.6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-====================================-=======================-=======================-==============================================================================
ii postgresql-9.6 9.6.6-1.pgdg80+1 amd64 object-relational SQL database, version 9.6 server
root@7be85c8651ab:/# apt-get update; apt-get install postgresql-plpython-9.6=9.6.6-1.pgdg80+1
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Get:2 http://apt.postgresql.org jessie-pgdg InRelease [56.4 kB]
Ign http://deb.debian.org jessie InRelease
Get:3 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:4 http://deb.debian.org jessie Release.gpg [2,373 B]
Get:5 http://deb.debian.org jessie Release [148 kB]
Get:6 http://security.debian.org jessie/updates/main amd64 Packages [612 kB]
Get:7 http://apt.postgresql.org jessie-pgdg/main amd64 Packages [141 kB]
Get:8 http://deb.debian.org jessie-updates/main amd64 Packages [23.2 kB]
Get:9 http://deb.debian.org jessie/main amd64 Packages [9,063 kB]
Get:10 http://apt.postgresql.org jessie-pgdg/9.6 amd64 Packages [1,699 B]
Fetched 10.3 MB in 6s (1,656 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libpython2.7
The following NEW packages will be installed:
libpython2.7 postgresql-plpython-9.6
0 upgraded, 2 newly installed, 0 to remove and 1 not upgraded.
Need to get 1,133 kB of archives.
After this operation, 3,878 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg/main postgresql-plpython-9.6 amd64 9.6.6-1.pgdg80+1 [52.0 kB]
Get:2 http://deb.debian.org/debian/ jessie/main libpython2.7 amd64 2.7.9-2+deb8u1 [1,081 kB]
Fetched 1,133 kB in 2s (475 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython2.7:amd64.
(Reading database ... 12580 files and directories currently installed.)
Preparing to unpack .../libpython2.7_2.7.9-2+deb8u1_amd64.deb ...
Unpacking libpython2.7:amd64 (2.7.9-2+deb8u1) ...
Selecting previously unselected package postgresql-plpython-9.6.
Preparing to unpack .../postgresql-plpython-9.6_9.6.6-1.pgdg80+1_amd64.deb ...
Unpacking postgresql-plpython-9.6 (9.6.6-1.pgdg80+1) ...
Processing triggers for postgresql-common (188.pgdg80+1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Setting up libpython2.7:amd64 (2.7.9-2+deb8u1) ...
Setting up postgresql-plpython-9.6 (9.6.6-1.pgdg80+1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
root@7be85c8651ab:/# dpkg -l postgresql-9.6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-====================================-=======================-=======================-==============================================================================
ii postgresql-9.6 9.6.6-1.pgdg80+1 amd64 object-relational SQL database, version 9.6 server
root@7be85c8651ab:/# dpkg -l postgresql-plpython-9.6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-====================================-=======================-=======================-==============================================================================
ii postgresql-plpython-9.6 9.6.6-1.pgdg80+1 amd64 PL/Python procedural language for PostgreSQL 9.6
root@7be85c8651ab:/#
docker-library devs, please keep this open if you don't mind.
Are there things we can fix in the image itself to make this upgrade issue not happen? I think the fix in #230 (comment) is the best we can really do (ie, use version pinning in sub-Dockerfile
s which install plpython
in order to make them not upgrade PostgreSQL accidentally):
FROM postgres:9.6
RUN apt-get update && apt-get install -y "postgresql-plpython-$PG_MAJOR=$PG_VERSION" && rm -rf /var/lib/apt/lists/*
This way, the install will either:
do what you expect (and give you the appropriate version of plpython
), or
error out during build (which is way better than successfully giving you an image that doesn't work properly when you try to run it)
This is how I install plpython in my image now.
First I tell apt to pin the versions of all the packages installed in the image - obviously, those are versions which were current when the image was built.
Then I do update and install plpython.
If there are any problems with the packages out there, in the repositories, esp. pgdg which may have been already updated by the time I build the image, this will fail at the build stage. This will not pull new PostgreSQL packages thus causing PostgreSQL to listen on another port.
FROM postgres:10
RUN apt-mark hold postgresql-10 postgresql-client-10 postgresql-common postgresql-client-common
RUN apt-get update -qq && apt-get install postgresql-plpython-10 -qq -y