Massive Docker noob here in dire need of help. There are two docker containers: simple-jar
and elk
. simple-jar
produces log files in /logs
directory within its container, and another application, elk
, needs to access these log files to do some processing on them.
- How can I share the
/logs
directory so thatelk
docker container can access it?
This is the Dockerfile for simple-jar
:
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
docker-compose.yml:
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:
- "9200:9200"
- "9300:9300"
simple-jar:
build:
context: pulsar_logging_consumer/
volumes:
- type: bind
source: ./pulsar_logging_consumer/logs
target: /usr/share/logs
read_only: true
ports:
- "6500:6500"
networks:
- elk
depends_on:
- elasticsearch
networks:
elk:
driver: bridge
volumes:
elasticsearch: