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:

  • Docker : find sendmail in other container
  • After using Docker-machine to reconfigure docker client how do I set it back to Docker for Windows hyperv
  • Docker & nginx - Internal links not working
  • Killing a Process in a Running Docker Container
  • How can i add a command to the meteor mupx start script?
  • Elastic Beanstalk Multi-Container Environment cannot mount fuse mount as docker volume
  • 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?

  • Minimize CentOS-based Docker image
  • How to build an Image using Docker API?
  • docker-compose postgresql persitent local storage
  • For a Docker container based implementation, does it make sense to run a pair of Kafka server and Zookeeper server inside the same container?
  • Postfix in Docker container can't resolve MX unless it gets restarted once
  • Private Github repositories in dockerized rails application during build
  • 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.