Postgres Docker Image: Failed to map database to host
I am using the official Postgres stock image from Docker Hub.
docker pull postgres
... I wanted to map a directory
in a Postgres container for my OS X host. So I tried this.
docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=mypass -v `pwd`/data:/var/lib/postgresql/data postgres
As a result, the Postgres container did not start correctly.
fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied initdb: removing contents of data directory "/var/lib/postgresql/data"
The goal I am trying to achieve is to keep my database data on the host machine so that I can start the postgres container and read (or load) the database from a previous instance. Am I on the right track or is this a silly way to achieve database stabilization?
source to share