How to start nodejs and filebeat in same contianer
I need to create a docker container with nodejs app and filebeat in same container. So filebeat will relay nodejs logs to my logstash server. I have created docker file and when i build the image it runs without error. But when i go inside container and see no files related to filebeat are created. NodeJS app runs as expected but filebeat is not working at all.
I have used the custom file given by filebeat https://www.elastic.co/guide/en/beats/filebeat/current/running-on-docker.html mentioned here
So can we run the nodeJS app and filebeat in same container? and if yes what i am doing wrong ?
Here is my docker file ---
# Test web app that returns the name of the host/pod/container servicing req
# Linux x64
FROM docker.elastic.co/beats/filebeat:7.13.4
COPY --chown=root:filebeat filebeat.yml /usr/share/filebeat/filebeat.yml
FROM node:current-alpine
LABEL org.opencontainers.image.title="Test node App" \
org.opencontainers.image.description="Create logs for Opensearch" \
org.opencontainers.image.authors="@user"
# Create directory in container image for app code
RUN mkdir -p /usr/src/app
# Copy app code (.) to /usr/src/app in container image
COPY . /usr/src/app
# Set working directory context
WORKDIR /usr/src/app
RUN mkdir -p /usr/src/app/logs
RUN touch /usr/src/app/logs/log.log
RUN touch /usr/src/app/logs/error_log.log
RUN ln -sf /proc/1/fd/1 /usr/src/app/logs/log.log
RUN ln -sf /proc/1/fd/1 /usr/src/app/logs/error_log.log
# Install dependencies from packages.json
RUN npm install
# Command for container to execute
CMD [ "node", "index.js" ]
Comments
Post a Comment