Docker Compose:卷已声明为外部卷,但找不到 [英] Docker Compose: Volume declared as external, but could not be found
本文介绍了Docker Compose:卷已声明为外部卷,但找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从docker运行外部卷样本yml撰写 v3文档给出我出现以下错误:
Running the external volume sample yml from docker compose v3 docs gives me the following error:
ERROR: Volume data declared as external, but could not be found. Please create the volume manually using `docker volume create --name=data` and try again.
这是yml代码:
version: '2'
services:
db:
image: postgres
volumes:
- data:/var/lib/postgresql/data
volumes:
data:
external: true
我在Windows 10上运行它。也尝试将版本设置为 3,但出现了相同的错误。
I`m running it on windows 10. Also tried to set version to '3' but got the same error.
推荐答案
根据错误消息的说明,您需要通过运行以下命令来创建卷:
As the error message specifies, you need to create the volume by running:
docker volume create data
在docker compose中将卷声明为外部卷时,表示该卷先前已创建后,您只需在撰写文件中引用它即可。
When you declare a volume as external in docker compose, it means that the volume has been previously created and you are just referencing it in the compose file.
这篇关于Docker Compose:卷已声明为外部卷,但找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文