Postgres Docker Image:無法將數據庫映射到主機

[英]Postgres Docker Image: Failed to map database to host


I'm using the stock official Postgres image from Docker Hub. docker pull postgres. I wanted to map the data directory in the Postgres container to my OS X host. So, I tried this.

我正在使用Docker Hub的官方Postgres圖片。碼頭工人拉postgres。我想將Postgres容器中的數據目錄映射到我的OS X主機。所以,我試過這個。

docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=mypass -v `pwd`/data:/var/lib/postgresql/data postgres

This resulted in the Postgres container failing to launch correctly.

這導致Postgres容器無法正確啟動。

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"

The goal I'm trying to achieve is to have my database data stored on the host machine, so that I can start a postgres container and have it read (or load) the database from a previous instance. Am I on the right track or is this a stupid way to achieve database persistence?

我想要實現的目標是將我的數據庫數據存儲在主機上,這樣我就可以啟動一個postgres容器並讓它從之前的實例讀取(或加載)數據庫。我是在正確的軌道上還是這是一種實現數據庫持久性的愚蠢方法?

1 个解决方案

#1


According to official documentation you should use boot2docker to resolve the issue. However, without it, you won't be able to mount container.

根據官方文檔,您應該使用boot2docker來解決問題。但是,如果沒有它,您將無法安裝容器。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/05/09/4ba097f0b1de141723740648eb3bb539.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com