通过 docker 在 Windows 上安装 Clickhouse 的主机数据目录权限

Data directory permissions on host for Clickhouse installation via docker on Windows

我有一个与以下 link 类似的问题,但在 powershell 中,因为我 运行 在 windows 10 中安装了一个 clickhouse docker 容器。

我的设置是 运行 这样的:

docker run -d -p 8124:8124 --name my_database --ulimit nofile=262144:262144 --volume=E:/:/var/lib/clickhouse yandex/clickhouse-server

E 盘是我 windows 计算机上的驱动器之一。

当 运行创建合并树 table 时,我似乎无法访问 /var/lib/clickhouse/data。似乎没有为 clickhouse 客户端提供访问此文件系统的足够权限。错误看起来是这样的:

Access to file denied: /var/lib/clickhouse/data/default/test_mergetree/tmp_insert_20150731_20150731_8_8_0

因为我在 powershell 中,所以我不确定我该如何解决这个问题。我正在尝试访问文件系统以授予 powershell 权限:

像这样

ICACLS "var/lib/clickhouse/data" /setowner "administrator"

但由于 clickhouse 已 docker 化,所以我似乎找不到路径:

The system cannot find the path specified.

我必须 运行 docker 作曲吗?还是我处理方法不对?

尝试 1

我已尝试 运行以下操作:

docker run --rm -i --entrypoint /bin/sh yandex/clickhouse-server -c id clickhouse

#got back:
uid=0(root) gid=0(root) groups=0(root)

#went into the system and ran
docker exec -it container-id bash 
chown -R 0:0 /var/lib/clickhouse

#got back
chown: cannot read directory '/var/lib/clickhouse/System Volume Information': Permission denied

原来这是一个尚未在 windows docker 桌面版中修复的问题:

https://github.com/docker/for-win/issues/39

卷挂载是必需的。但是我通过将磁盘映像更改为目标主机驱动器来解决这个问题。在设置 -> 高级 -> 下将虚拟硬盘映像更改为您想要的驱动器,您可以在该驱动器内写入。请注意,您仍然无法访问原始数据。

您应该 运行 docker 和 Linux 中的 clickhouse 而不是 Windows。