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:
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?
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.