2017-08-11 45 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