Docker Community Forums

Share and learn in the Docker community.

Can't use an older version of postgres

I have created a docker-compose.yml in which I try to specify an older version of postgres.

The first few lines of the yaml file are:

version: “3”
services:
db:
image: postgres:9.6

When I build the ‘db’ container I see the following:

docker-compose build --no-cache db
Building db
Step 1/7 : FROM postgres:12.0
—> f88dfa384cc4

It is getting postgres version 12 rather than 9.6 as I specified.

What am I doing wrong?

thanks

Do you have a Dockerfile to build the image for this service?

psql is the command line interface and its version can be independent of the Postgres server.

To get the version of the server software run SELECT version() against the database you are connected to (from within psql). Though it is possible to interact with different versions, some obvious limitations apply. I suggest you uninstall the outdated psql as well and use the version matching the server.