I can't access mounted volume of docker-postgres from host

I create my container like this:

docker run --name postgresql -itd --restart always \
--publish 5432:5432 \
--volume /my/local/host:/var/lib/postgresql \
sameersbn/postgresql:9.4-11

but, when I do ls on the root directory, I see something like this:

  • ECONNREFUSED 127.0.0.1:3306 to mysql container inside jenkins
  • docker-compose build doesn't re-create some slices of my container, resulting in partially obsolete code
  • can i use boot2docker in production ? CoreOS Vs boot2docker
  • Docker-compose specify config file
  • Flag provided but not defined -d while running docker container
  • what's the data's meaning collected by cadvisor?
  • drwxrwxr-x  3 messagebus messagebus 4,0K Ιαν  10 00:44 host/
    

    or, in other words, I cannot access the /my/local/host directory. I have no idea about the messagebus user. is that normal? if this is the case, then how could I move the database from one machine to another in the future?

  • multiple log_opts for docker logging
  • Getting error while runnig neo4j-mazerunner project
  • Error response from bash script calling OCRmyPDF through Docker
  • Cannot connect to the Docker daemon on ubuntu 14.04
  • Difference between docker run --user and --group-add parameters
  • New to Docker - how to essentially make a cloneable setup?
  • One Solution collect form web for “I can't access mounted volume of docker-postgres from host”

    Try using a data container to hold your DB data. The pattern is described in the docs and is designed to promote clean separation between run-time and data.

    $ docker create -v /var/lib/postgresql --name dbdata sameersbn/postgresql:9.4-11 
    $ docker run --name postgresql1 -itd --restart always \
    --publish 5432:5432 \
    --volumes-from dbdata
    sameersbn/postgresql:9.4-11
    

    A separate data container makes backup and recovery simpler and more obvious

    docker run --volumes-from dbdata -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /var/lib/postgresql
    

    The following posting I think gives a good explanation of data containers:

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.