2017-08-11 44 views
0

我試圖在postgres中執行數據持久性。但是當我想要將數據文件夾裝入我的本地文件時,出現此錯誤。Postgres Docker容器數據無法安裝到本地

fixing permissions on existing directory /var/lib/postgresql/data ... ok 
creating subdirectories ... ok 
selecting default max_connections ... 100 
selecting default shared_buffers ... 128MB 
selecting dynamic shared memory implementation ... posix 
creating configuration files ... ok 
LOG: could not link file "pg_xlog/xlogtemp.25" to "pg_xlog/000000010000000000000001": Operation not permitted 
FATAL: could not open file "pg_xlog/000000010000000000000001": No such file or directory 
child process exited with exit code 1 
initdb: removing contents of data directory "/var/lib/postgresql/data" 
running bootstrap script ... 

這是我的YAML文件

version: '3.1' 

services: 

    postgres: 
    restart: always 
    image: postgres:9.6.4-alpine 
    ports: 
     - 8100:5432 
    volumes: 
     - ./pgdata:/var/lib/postgresql/data 
    environment: 
     POSTGRES_PASSWORD: root 

我在Windows上使用泊塢窗工具箱。 Virtual Box中的碼頭機。

回答

0

它看起來像您使用共享數據目錄(主機目錄共享到虛擬)進行數據庫存儲。

只有兩個選項意義:

1)你有目錄的權限小事

2)你打一個已知的問題(谷歌)與一些VirtualBox和也版本的VMware上一些! Windows版本中,不能在從主機共享到虛擬機的目錄中創建符號鏈接。 (2),一種解決方法是不使用共享文件夾來保存數據。

無論哪種方式,這都是Docker鏡像本身的提供者或虛擬化器(vbox,vmware等)的提供者應該解決的問題。

這不是Windows操作系統或PostgreSQL的錯。

1

對於windows docker工具箱,它看起來必須是/ mnt/sda1/var/lib/docker/volumes/psql/_data。這爲我工作

docker run -it --name psql -p 5432:5432 -v psql:/var/lib/postgresql/data postgres:9.5-alpine 

"Mounts": [ 
      { 
       "Type": "volume", 
       "Name": "psql", 
       "Source": "/mnt/sda1/var/lib/docker/volumes/psql/_data", 
       "Destination": "/var/lib/postgresql/data", 
       "Driver": "local", 
       "Mode": "z", 
       "RW": true, 
       "Propagation": "" 
      } 

搬運工量LS

DRIVER    VOLUME NAME 
local    65f253d220ad390337daaacf39e4d17000c36616acfe1707e41e92ab26a6a23a 
local    761f7eceaed5525b70d75208a1708437e0ddfa3de3e39a6a3c069b0011688a07 
local    8a42268e965e6360b230d16477ae78035478f75dc7cb3e789f99b15a066d6812 
local    a37e0cf69201665b14813218c6d0441797b50001b70ee51b77cdd7e5ef373d6a 
local    psql 

請參閱本作的詳細信息:bad mount