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 \

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

  • Error 500 when running exec start with Docker Remote API
  • Docker unable to start an interactive shell if the image has an entry script
  • docker run command output
  • CI and CD implementation issues
  • Vagrant: Passing docker run arguments to multiple containers using vagrant
  • What does volume_from do if there are no volumes in the volume container?
  • 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?

  • Docker Volume Containers for database, logs and metrics
  • Ubuntu/UFW: How to tell Docker not to expose all ports?
  • couchbase - [Errno 113] No route to host
  • etcd - Is it possible to setup pubsub using etcd?
  • ERROR: Version in “./docker-compose.yml” is unsupported. You might be seeing this error because you're using the wrong Compose file version
  • Running an Oracle XE Docker image on a Redhat Host
  • 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

    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.