title: Write docker logs to external log file
body: <p>We have a number of nodejs based microservices and all of them are running as docker containers.</p>
  
  <p>Below is the content of dockerfile:</p>
  
  <pre><code>FROM keymetrics/pm2-docker-alpine:latest
  
  ARG ENVIRONMENT
  ARG PORT
  
  ENV PORT $PORT
  ENV ENVIRONMENT $ENVIRONMENT
  
  RUN apt-get update -qq
  
  
  RUN apt-get install --yes curl
  RUN curl --silent --location https://deb.nodesource.com/setup_6.x | bash -
  RUN apt-get install --yes nodejs
  RUN apt-get install --yes build-essential vim
  
  
  RUN mkdir /database_service
  ADD . /database_service
  WORKDIR /database_service
  
  RUN npm install -g path
  RUN npm cache clean
  
  EXPOSE $PORT
  
  CMD [ "npm", "start", $PORT, $ENVIRONMENT ]
  </code></pre>
  
  <p>Below is the command used to run the container</p>
  
  <pre><code>sudo docker run -p ${EXTERNAL_PORT_NUMBER}:${INTERNAL_PORT_NUMBER} --network 
  ${NETWORK} --name ${SERVICE_NAME} --restart always -m 2048M --memory-swap -1 
  -itd ${ORGANISATION}/${SERVICE_NAME}:${VERSION}
  </code></pre>
  
  <p>I am looking for a way write contents of the logs generated by docker node based service to the external file on the Linux VM machine. If someone can help with sample command that will help.</p>