Relative path does not work with named volumes in docker-compose.yml

I need to make a named volume using the relative path to the folder where the command is running docker-compose

.

Here is the volume definition in the docker-compose.yml file

volumes:
  esdata1:
   driver: local 
   driver_opts:
      type: none
      device: ./esdata1
      o: bind

      

It seems that docker-compose doesn't create the folder if it doesn't exist , but even if the folder is created before, I always get this error:

ERROR: for esdata  Cannot create container for service esdata: error while mounting volume with options: type='none' device='./esdata1' o='bind': no such file or directory

      

NOTE: This might be silly, but esdata

- this is a service using a named volume

  esdata:
    ...
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ...

      

What am I missing here?

Perhaps the relative path ./

does not point to the folder it is running in docker-compose

(I tried ~/

using a folder relative to the user's home, but I got the same error).

Thanks in advance,

PS: If I use an absolute path it works like a charm

+3


source to share





All Articles