Docker Compose: Volume declared as external, but could not be found

眉间皱痕 提交于 2019-12-06 11:36:06

问题


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.

This is the yml code:

version: '2'

services:
  db:
    image: postgres
    volumes:
      - data:/var/lib/postgresql/data

volumes:
  data:
    external: true

I`m running it on windows 10. Also tried to set version to '3' but got the same error.


回答1:


As the error message specifies, you need to create the volume by running:

docker volume create data

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.



来源:https://stackoverflow.com/questions/47479767/docker-compose-volume-declared-as-external-but-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!