在Windows 10中使用docker-compose时,不会在Scylla中创建卷 [英] Volume isn't created in Scylla when using docker-compose in Windows 10
问题描述
我刚刚开始学习Docker和docker-compose,我想尝试ScyllaDB(数据库).我想通过带有持久性存储的docker-compose在Docker中启动ScyllaDB的单个实例.永久性存储应保存在相对于我的docker-compose文件的文件夹'target'中.问题是我看不到正在创建任何文件夹,但是docker-compose似乎可以保留数据,但是我不确定在哪里可以找到ScyllaDB创建的文件.循序渐进的再现路径:
I just started learning Docker and docker-compose and I want to try out ScyllaDB (database). I want to start a single instance of ScyllaDB in Docker through docker-compose with persistent storage. The persistent storage should be saved in folder 'target' relative to my docker-compose file. The problem is that I don't see any folder being created, but docker-compose seems to persist the data, but I am not sure where I can locate the files that ScyllaDB created. Step by step reproduction path:
- 使用以下内容创建一个docker-compose.yml(/var/lib/scylla应该根据 docker-compose.yml
version: '3' services: b-scylla: image: "scylladb/scylla:4.3.1" container_name: b-scylla volumes: - ./target:/var/lib/scylla ports: - "127.0.0.1:9042:9042" - "127.0.0.1:9160:9160"
- 这不会产生任何结果:
$ docker volume ls
- 启动docker-compose并等待一分钟,以便ScyllaDB启动:
$ docker-compose up -d
- 这仍然没有任何结果:
$ docker volume ls
.我希望Docker应该创建一个卷(./target/). - 在ScyllaDB中保留一些数据以验证数据是否保存在某处:
- This does not give any result:
$ docker volume ls
- Start up docker-compose and wait a minute for ScyllaDB to start up:
$ docker-compose up -d
- This does still not give any result:
$ docker volume ls
. I expect that Docker should created a volume (./target/). - Persist some data in ScyllaDB to verify that the data is saved somewhere:
运行以下命令:
$ docker exec -it b-scylla cqlsh $ create keyspace somekeyspace with replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': 2 };
- 创建的键空间保存在某个地方,但我不知道在哪里.我希望它只是在目标文件夹中,但是甚至没有创建该文件夹.当我重新启动docker-compose时,键空间仍然存在,因此数据保存在某个地方,但是在哪里?
推荐答案
您正在使用短语法";用于数据挂载( https://docs.docker.com/compose/compose-file/compose-file-v3/#short-syntax-3 )正在创建绑定挂载点.绑定不是卷.无法使用
docker volume ls
检查它们.您可以使用docker inspect {container}
了解有关您的挂载的信息.You are using the "short syntax" for data mounting (https://docs.docker.com/compose/compose-file/compose-file-v3/#short-syntax-3) that is creating a mount point binding. Bindings are not volumes. They can't be checked with the
docker volume ls
. You can find out about your mounts withdocker inspect {container}
.但是,在绑定安装后,Scylla图像对我而言无法正确启动.我看到了在安装目录中写入sstables时出现的恒定文件系统错误:
However, Scylla image does not start for me correctly with the bind mounting. I saw constant file system errors for writing sstables in mounted directory:
version: '3' services: b-scylla: image: "scylladb/scylla:4.3.1" container_name: b-scylla volumes: - ./target:/var/lib/scylla
$ docker compose up -f .\test.yaml
b-scylla | INFO 2021-03-04 07:24:53,132 [shard 0] init - initializing batchlog manager b-scylla | INFO 2021-03-04 07:24:53,135 [shard 0] legacy_schema_migrator - Moving 0 keyspaces from legacy schema tables to the new schema keyspace (system_schema) b-scylla | INFO 2021-03-04 07:24:53,136 [shard 0] legacy_schema_migrator - Dropping legacy schema tables b-scylla | ERROR 2021-03-04 07:24:53,168 [shard 0] table - failed to write sstable /var/lib/scylla/data/system/truncated-38c19fd0fb863310a4b70d0cc66628aa/mc-8-big-Data.db: std::system_error (error system:2, No such file or directory)
我没有找到导致这种情况的原因,但是该目录是可写的,并且包含大多数正常的初始数据-保留的commitlog段和system ks数据文件夹.
I did not find out what causes this, but the dir is writable and contains most of the normal initial data - reserved commitlog segments and system ks data folders.
实际有效的方法是使用卷
What actually works is using Volumes:
version: '3' services: b-scylla: image: "scylladb/scylla:4.3.1" container_name: b-scylla volumes: - type: volume source: target target: /var/lib/scylla volume: nocopy: true volumes: target:
$ docker compose up -f .\test.yaml
$ docker volume ls DRIVER VOLUME NAME local 6b57922b3380d61b960110dacf8d180e663b1ce120494d7a005fc08cee475234 local ad220954e311ea4503eb3179de0d1162d2e75b73d1d9582605b4e5c0da37502d local projects_target $ docker volume inspect projects_target [ { "CreatedAt": "2021-03-04T07:20:40Z", "Driver": "local", "Labels": { "com.docker.compose.project": "projects", "com.docker.compose.version": "1.0-alpha", "com.docker.compose.volume": "target" }, "Mountpoint": "/var/lib/docker/volumes/projects_target/_data", "Name": "projects_target", "Options": null, "Scope": "local" } ]
Scylla在此模式下成功启动.
And Scylla starts successfully in this mode.
您当然可以使用以下方法将此卷安装到任何其他容器上:
You of course can mount this volume to any other container with:
$ docker run -it --mount source=projects_target,target=/app --entrypoint bash scylladb/scylla:4.3.1
或通过WSL访问它(在Docker桌面(Windows)中定位数据卷):
or accessing it via WSL (Locating data volumes in Docker Desktop (Windows)):
$ \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\projects_target\_data
这篇关于在Windows 10中使用docker-compose时,不会在Scylla中创建卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 这不会产生任何结果: