5

Docker Toolbox v. 1.13.1aWindows 7 Pro Service pack 1 x64操作系统上运行。和Virtual Box Version 5.1.14 r112924

official postgres image当我尝试从禁用卷的 Docker Hub运行任何 docker 映像时,它工作正常!

但是当我enable the volumes失败

我尝试了所有官方文档

虚拟机根据需要具有共享文件夹,并且还full access必须 共享文件夹屏幕截图

在我的 postgresql 示例中,它会因以下原因而崩溃log

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
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
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... LOG:  could not link file "pg_xlog/xlogtemp.27" 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"

我知道它的问题folder permissions。但是有点卡住了!提前致谢_

4

2 回答 2

2

I've been busy with this problem all day and my conclusion that it's currently simply not possible to run postgresql inside a docker container while keeping your data persistent in a separate volume.

I even tried running the container without linking to a volume and copying the data that was originally in /var/lib/postgresql into a folder of my host OS (Windows 10 Home), then copy that into the folder that got then linked to the container itself.

Alas, I got the next error:

FATAL:  data directory "/var/lib/postgresql/data/pgadmin" has wrong ownership
HINT:  The server must be started by the user that owns the data directory.

In conclusion: There's something going wrong with the ownership and the correct user owning it and to be able to fix it, you'll need a unix commandline on Windows that is able to run docker (something currently not possible with Bash on Ubuntu on Windows that is running using Ubuntu 16.04 binaries).

Maybe, in the future, you'll be able to run the needed commands (found here, under Arbitrary --user Notes), but these are *nix commands and powershell (started by Kitematic) can't run those. Bash for Ubuntu for Windows could run those, but that shell has no connection to the docker daemon/service on windows...

TL;DR: Lost a day of work: It is currently impossible on Windows.

于 2017-04-08T22:32:35.090 回答
0

我也一直在尝试解决这个问题..

起初我认为这是一个符号链接问题(因为第一个错误在“无法链接..不允许操作”上失败)

为确保允许符号链接,您必须:

  1. 在 virtualbox 中共享一个文件夹
  2. 以管理员身份运行 virtualbox(如果您的帐户在管理员组中)右键单击virtualbox.exe并选择以管理员身份运行
  3. 如果您的帐户不是管理员,请使用secpol.msc>“本地策略-用户权限分配”添加符号链接权限,将您的用户添加到“创建符号链接”
  4. 在 virtualbox 中为您的共享文件夹启用符号链接:

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARED_FOLDER_NAME 1

或者,您也可以使用c:\User\username默认 dockertools 安装启用的共享文件夹和符号链接

现在我可以在 docker 容器的共享文件夹中创建符号链接.. 但我仍然有同样的错误“无法链接......不允许操作”

所以原因必须在其他地方......如你所说,在文件权限中,但我不明白为什么?

于 2017-06-09T12:15:18.150 回答