我正在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
的问题。但有点卡住了!
提前大量谢谢
答案 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上失败;无法链接..操作不允许)
为了确保允许使用符号链接,您必须:
virtualbox.exe
并选择以管理员身份运行secpol.msc
>添加符号链接权限"本地政策 - 用户权利分配"将您的用户添加到"创建符号链接" VBoxManage setextradata VM_NAME VBoxInternal2 / SharedFoldersEnableSymlinksCreate / SHARED_FOLDER_NAME 1
或者你也可以使用默认的dockertools安装共享和符号链接的c:\User\username
文件夹
现在我可以在docker容器的共享文件夹中创建符号链接..但我仍然有相同的错误"无法链接...操作不允许"
所以理由必须在其他地方...在你说的文件权限中,但我不明白为什么?