启用卷时,无法启动任何容器Docker Toolbox

时间:2017-03-30 12:30:38

标签: docker virtualbox virtualization docker-toolbox

我正在Docker Toolbox v. 1.13.1a操作系统上运行Windows 7 Pro Service pack 1 x64。 与Virtual Box Version 5.1.14 r112924

当我尝试运行任何泊坞窗图片时,例如来自Docker Hub的official postgres image禁用了卷,它运行正常!

但当我enable the volumes 失败时

我尝试了所有官方文件

VM根据需要具有共享文件夹,并且还具有full access shared folder screenshot

如果是我的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 的问题。但有点卡住了! 提前大量谢谢

2 个答案:

答案 0 :(得分: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.

答案 1 :(得分:0)

我一直试图解决这个问题..

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

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

  1. 在virtualbox中共享文件夹
  2. 以管理员身份运行virtualbox(如果您的帐户位于管理员组中)右键单击virtualbox.exe并选择以管理员身份运行
  3. 如果您的帐户不是管理员,请使用secpol.msc>添加符号链接权限"本地政策 - 用户权利分配"将您的用户添加到"创建符号链接"
  4. 为virtualbox中的共享文件夹启用符号链接:
  5. VBoxManage setextradata VM_NAME VBoxInternal2 / SharedFoldersEnableSymlinksCreate / SHARED_FOLDER_NAME 1

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

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

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