'docker postgresql recover data folder

I'm trying to restore postgresql pgdata folder on a new postgresql/postgis instance running on docker. In fact i had a postgresql/postgis cluster installed on centos7, soon i'll be migrating to new servers so i thought about passing my server to docker, i'm trying to do so by using official postgresql/postgis image:

  db:
image: "postgis/postgis:10-3.0"
#command: ["postgres", "-c", "config_file=/etc/postgresql.conf"]
environment:
  - POSTGRES_PASSWORD=postgres
ports:
  - "5439:5432"
volumes:
  - /mnt/disk1/pgdata/10/data:/var/lib/postgresql/data

So i've done some research on the net and i found how to perssist data with docker volumes, however i already have an existing pgdata folder and when i run my docker-compose file i get errors in the postgresql instance logs, check below:

initdb: directory "/var/lib/postgresql/data" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/var/lib/postgresql/data" or run initdb
with an argument other than "/var/lib/postgresql/data".

Has anyone gone throught this already ? Any comment or help is welcomed, thank you in advance .

Have a nice day



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source