<p>I don't think volumes can be specified with relative paths. 
Put an absolute path instead of <code>./elastic-stack-ca.p12</code> and you should be fine.</p>

CC BY-SA 4.0
2020-05-07T15:34:49.893Z
2020-05-07T15:34:49.893Z
Max Uppenkamp
<p>Below is except of my docker-compose.yml file</p>

<p>I am trying to mount from host file inside the container, which works i.e. able to mount
but then I need to give it permission (my clumsy chown command, below).</p>

<p>I am not sure where to run it as wherever I place my (command: chown,-R,elasticsearch,/usr/share/elasticsearch/config/) </p>

<p>It gives me error that 'no such file or directory' which I think: my code run before volume is attached.</p>

<p>I tried placing it after container_name as well, same 'no such file or directory'</p>

<p>Any advise how to do it?</p>

<pre><code>image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch


volumes:
  - ./elastic-stack-ca.p12:/usr/share/elasticsearch/config/elastic-stack-ca.p12
  - esdata1:/usr/share/elasticsearch/data
*command: chown,-R,elasticsearch,/usr/share/elasticsearch/config/*
</code></pre>

<p>Here is full yml, if it is helpful</p>

<pre><code>    version: '3'

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch
    command:
     chown,-R,elasticsearch,/usr/share/elasticsearch/config/
    environment:
      - node.name=elasticsearch
      - discovery.seed_hosts=elasticsearch
      - cluster.initial_master_nodes=elasticsearch
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./elastic-stack-ca.p12:/usr/share/elasticsearch/config/elastic-stack-ca.p12
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200

  kibana:
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana
    environment:
      ELASTICSEARCH_URL: "http://elasticsearch:9200"
      ELASTICSEARCH_USERNAME: "kibana"
      ELASTICSEARCH_PASSWORD: "kibana"
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

volumes:
  esdata1:
    driver: local
</code></pre>

CC BY-SA 4.0
2020-04-30T08:29:30.087Z
Hi, welcome to the club J Show full logs pls
Yasen
CC BY-SA 4.0
2020-04-30T12:04:00.290Z
thanks here is full logs:  elasticsearch    | /usr/local/bin/docker-entrypoint.sh: line 37: /usr/share/elasticsearch/chown,-R,elasticsearch,/usr/share/elasticsearch/config/: No such file or directory
elasticsearch exited with code 1
x0rcist
CC BY-SA 4.0
2020-05-02T23:33:28.687Z
any thoughts I have shared the edited full file.
x0rcist
<docker><docker-compose><dockerfile>
Grant access permission to file when mounting from host
x0rcist
# Grant access permission to file when mounting from host

(Asked by: username_0 on 2020-04-30)

Below is except of my docker-compose.yml file
I am trying to mount from host file inside the container, which works i.e. able to mount
but then I need to give it permission (my clumsy chown command, below).
I am not sure where to run it as wherever I place my (command: chown,-R,elasticsearch,/usr/share/elasticsearch/config/) 
It gives me error that 'no such file or directory' which I think: my code run before volume is attached.
I tried placing it after container_name as well, same 'no such file or directory'
Any advise how to do it?
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
container_name: elasticsearch


volumes:
  - ./elastic-stack-ca.p12:/usr/share/elasticsearch/config/elastic-stack-ca.p12
  - esdata1:/usr/share/elasticsearch/data
*command: chown,-R,elasticsearch,/usr/share/elasticsearch/config/*

Here is full yml, if it is helpful
    version: '3'

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
    container_name: elasticsearch
    command:
     chown,-R,elasticsearch,/usr/share/elasticsearch/config/
    environment:
      - node.name=elasticsearch
      - discovery.seed_hosts=elasticsearch
      - cluster.initial_master_nodes=elasticsearch
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"

    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./elastic-stack-ca.p12:/usr/share/elasticsearch/config/elastic-stack-ca.p12
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200

  kibana:
    image: docker.elastic.co/kibana/kibana:7.6.2
    container_name: kibana
    environment:
      ELASTICSEARCH_URL: "http://elasticsearch:9200"
      ELASTICSEARCH_USERNAME: "kibana"
      ELASTICSEARCH_PASSWORD: "kibana"
    ports:
      - 5601:5601
    depends_on:
      - elasticsearch

volumes:
  esdata1:
    driver: local

**Tags:** docker, docker-compose, dockerfile

> **Comments:**
> **username_1**: Hi, welcome to the club J Show full logs pls  
> **username_0**: thanks here is full logs:  elasticsearch    | /usr/local/bin/docker-entrypoint.sh: line 37: /usr/share/elasticsearch/chown,-R,elasticsearch,/usr/share/elasticsearch/config/: No such file or directory elasticsearch exited with code 1  
> **username_0**: any thoughts I have shared the edited full file.  

---

## 1 answers

### Answer by username_2 on 2020-05-07. Score: 1

I don't think volumes can be specified with relative paths.
Put an absolute path instead of `./elastic-stack-ca.p12` and you should be fine.


---

