-p 127.0.0.1:5432:5432 instead of -p 5432:5432. If you don’t explicitly tell it to run on localhost, it’ll run on0.0.0.0 which means other folks on the same network will be able to reach it. https://hub.docker.com/_/postgres => Gives a lot of info regarding docker secrets which should be the way forward.
docker pull postgres
mkdir -p $HOME/docker/volumes/postgres
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 127.0.0.1:5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres
OR
docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 0.0.0.0:5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres:9.6