title: Sharing a created directory within a Docker container to another Docker container?
body: <p>Massive Docker noob here in dire need of help. There are two docker containers: <code>simple-jar</code> and <code>elk</code>. <code>simple-jar</code> produces log files in <code>/logs</code> directory within its container, and another application, <code>elk</code>, needs to access these log files to do some processing on them.</p>
  <ol>
  <li>How can I share the <code>/logs</code> directory so that <code>elk</code> docker container can access it?</li>
  </ol>
  <p>This is the Dockerfile for <code>simple-jar</code>:</p>
  <pre><code>FROM openjdk:latest
  COPY target/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar /usr/src/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar
  EXPOSE 6650
  CMD java -jar /usr/src/pulsar_logging_consumer-1.0-SNAPSHOT-jar-with-dependencies.jar 
  </code></pre>
  <p>docker-compose.yml:</p>
  <pre><code>version: '3.2'
  
  services:
    elk:
      build:
        context: elasticsearch/
        args:
          ELK_VERSION: $ELK_VERSION
      volumes:
        - type: bind
          source: ./elasticsearch/config/elasticsearch.yml
          target: /usr/share/elasticsearch/config/elasticsearch.yml
          read_only: true
        - type: volume
          source: elasticsearch
          target: /usr/share/elasticsearch/data
      ports:
        - &quot;9200:9200&quot;
        - &quot;9300:9300&quot;
  
    simple-jar:
      build:
        context: pulsar_logging_consumer/
      volumes:
        - type: bind
          source: ./pulsar_logging_consumer/logs
          target: /usr/share/logs
          read_only: true
      ports:
        - &quot;6500:6500&quot;
      networks:
        - elk
      depends_on:
        - elasticsearch
  
  networks:
    elk:
      driver: bridge
  
  volumes:
    elasticsearch:
  </code></pre>