I am trying to start a postgresql docker container which is of version 10.5.
But before that I have used 9.6 version in the same docker-compose.yml file and there is no data populated in the database.
And now after changing the version of postgres container, I'm not able to run the docker-compose up. It is throwing the below error.
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.5 (Debian 10.5-2.pgdg90+1)
This is how the docker-compose.yml file looks like.
version: '2'
services:
postgres_service:
container_name: postgresql_container
restart: always
image: postgres:10.5
volumes:
- postgres-data:/var/lib/postgresql/data
- ./postgresql/init:/docker-entrypoint-initdb.d
ports:
- "5432:5432"
environment:
- POSTGRES_USER=admin
- POSTGRES_PASSWORD=password
volumes:
postgres-data:
driver: local
Can someone please let me know where the issue is. Where am I making mistake? Do I need to delete any volumes before proceeding with the new postgres version?
I also have postgresql installed in my local.
postgres=# select version();
version
-------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 10.10 (Ubuntu 10.10-1.pgdg18.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit
(1 row)
Will this cause any issue?
Do I need to delete any volumes before proceeding with the new postgres version?
: Yes, you should. – Maleate/var/lib/postgresql/10/main/
. But still getting the same issue. Is that the volume that is supposed to be deleted? I don't see any/var/lib/postgresql/data
in my machine. – Jaclynjacopostgres-data
this one, remove it because when ever you restart your container all files inside that folder will be mapped into your postgresql container – Maleatepostgres-data
folder in my machine. Not sure where it is. Not in project folder or inroot - /
– Jaclynjacopostgres-data
in the location. – Jaclynjacopostgresql
. – Jaclynjaco