Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 the version to '3' but got the same error.

like image 771
ramiwi Avatar asked Nov 24 '17 20:11

ramiwi


People also ask

What is external in Docker compose?

external: True flag is used to make the containers join a pre-existing network instead. From docs: external. If set to true, specifies that this network has been created outside of Compose. docker-compose up does not attempt to create it, and raises an error if it doesn't exist.

What does external volume mean?

I found out that external volume is just a volume that has been created outside of Docker Compose and it is still located inside docker's vm: C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.


1 Answers

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.

OR

allow dockercompse to auto create the volume so just remove "external: true"

like image 151
yamenk Avatar answered Oct 12 '22 21:10

yamenk