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
docker docker-compose


source to share


No one has answered this question yet

See similar questions:

4
Relative path with docker - collecting shared volumes

or similar:

165
How to mount one file per volume
77
How to mount local volumes in a docker machine
41
How to store data in a docked postgres database using volumes
8
Can we mount named volume subdirectories in docker?
4
Relative path with docker - collecting shared volumes
1
Is there a way to select the default named volumes path in docker?
1
Docker secrets in docker-compose.yml
0
tutum stackfile with relative path volume
0
Docker Compose Relative Paths vs. Docker Scope
0
How do I add a volume from another server to my docker-compose file



All Articles
Loading...
X
Show
Funny
Dev
Pics