Relative path not working with named volumes in the docker-compose.yml

爷,独闯天下 提交于 2019-12-06 02:58:07

问题


I need to make a named volume use a relative path to the folder where the docker-compose command is executed.

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

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

It seems that docker-compose do not create the folder if it does not exist, but even when the folder is created before lauching docker I'm always getting 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 is maybe silly, but esdata is the service that use the named volume

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

What I'm missing here?

Maybe the relative path ./ does not point to the folder where the docker-compose is executed (I've tried with ~/ to use a folder relative 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


回答1:


I encountered exactly the same issue. It seems that you have done nothing wrong. This is just not yet implemented in Docker : https://github.com/docker/compose/issues/6343

Not very nice for portability...



来源:https://stackoverflow.com/questions/42961256/relative-path-not-working-with-named-volumes-in-the-docker-compose-yml

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