docker - 如何找到所有未命名的模块
问题描述
我得到了码头工人撰写:
version: '2'
services:
elasticsearch:
image: 'elasticsearch:7.9.1'
environment:
- discovery.type=single-node
ports:
- '9200:9200'
- '9300:9300'
volumes:
- /var/lib/docker/volumes/elastic_search_volume:/usr/share/elasticsearch/data:rw
当我运行时:
docker volume ls
我看不到任何结果。如何列出未命名的卷?
解决方案
docker volume ls
正如您所展示的,它将列出所有存在的卷。
但是,在docker-compose.yml
您显示的文件中,您没有创建命名或匿名卷。相反,您正在创建绑定挂载以将主机目录连接到容器文件系统空间。这些在技术 Docker 意义上不被视为“卷”,并且docker volume
命令不会显示或操作它们。
直接接触/var/lib/docker
通常不是最佳实践。最好让 Docker Compose 为您管理命名卷:
version: '2'
services:
elasticsearch:
volumes:
# No absolute host path, just the volume name
- elastic_search_volume:/usr/share/elasticsearch/data:rw
volumes:
elastic_search_volume:
# Without this line, Compose will create the volume for you.
# With this line, Compose expects it to already exist; you may
# need to manually `docker volume create elastic_search_volume`.
# external: true
推荐阅读
- python-3.x - 如何在 URL 位置将 DataFrame 导出为 Excel
- r - R中的复杂ggplot - 半圆形条形图
- reactjs - 在 axios 上使用 uri 的问题
- sql - SQL 转换为工作日和 hh:mm
- html - 使此内容可编辑以在 Firefox 和 Edge 上工作
- nim-lang - 是否可以在 Nim 中破坏序列?
- ruby-on-rails - Rails Rswag Swagger UI 未正确发送标头
- javascript - 快递限制上传速度
- github - 为什么当我点击我的 github 页面中的链接时它显示“404 page not found”?
- c++ - 具有相互引用的 C++ 模板实例化