Docker-comppos copies files as folder

I am trying to copy elasticsearch.yml using CORS from my host to a container using the docker-compose volume option. But when I copy the config folder it copies the elasticsearch.yml file into it as a folder.

Here is my dock file:

version: "3"

services:  
elasticsearch1:  
    container_name: my_container_name
    image: elasticsearch
    environment:
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    volumes:
      - /config/:/usr/share/elasticsearch/config/
    ports:
      - '9200:9200'
      - '9300:9300'

      

And this is the error message I get when you start docker:

Exception in thread "main" SettingsException [Failed to load settings from /usr/share/elasticsearch/config/elasticsearch.yml]; inested: IOException [is a directory];

I also tried copying to the tmp folder and the file was listed as a folder:

drwxr-xr-x 2 root root 40 Jul 6 08:25 elasticsearch.yml

What am I doing wrong?

+3


source to share


1 answer


With Docker for Windows and Docker for Mac, you run docker inside a virtual machine and install directories from inside that virtual machine into your container. When a file or directory does not exist inside the VM, it will be set as an empty Docker folder as the default behavior (this behavior seems to change with swarm mode).

To get a folder from a Windows host in a VM where it can be mapped to a container, you need to go to docker settings and configure shared drives:



https://docs.docker.com/docker-for-windows/#shared-drives

+1


source







All Articles