how to centralized log file on docker container?

How to centralized log file on docker container?

This log file is not in /var/lib/docker/container/*/

  • Understanding Docker best practice and running webservers
  • Cleanup disk space occupied by Docker images
  • Django channels and docker-compose error
  • Makefile - append to command
  • Why am I seeing docker.io infront of the docker images repository name?
  • How can kubernetes dynamically expose my docker port?
  • This log file is like catalina.out or another log file in container.
    (this file can be stdout/err or not).

    Many solution is almost about stdout/err( /var/lib/docker/container/* ).

    But I want to centralized log file in container to use ELK or Fluentd.

    Help me please.

  • Java ee api gets 404 on payara production server
  • Docker-machine resource limit
  • How to use stdin, stdout and stderr streams after attaching to a container using Docker api?
  • How do I filter docker swarm nodes by label?
  • How to deploy Kubernetes with Docker locally?
  • Hosting Wordpress with docker on Azure
  • One Solution collect form web for “how to centralized log file on docker container?”

    You could use a forwarder container inside your pod and share a volume for the log directory, as follows:

    kind: ReplicationController
    apiVersion: v1
    metadata:
      name: tomcat
      labels:
        app: tomcat
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            app: tomcat
        spec:
          containers:
          - name: tomcat
            image: tomcat
            volumeMounts:
            - name: tomcat-logs
              mountPath: /tomcat/log
              readOnly: false
          - name: logstash-forwarder
            image: apopelo/logstash-forwarder
            volumeMounts:
            - name: tomcat-logs
              mountPath: /var/log/tomcat
              readOnly: true
          volumes:
          - name: tomcat-logs
            emptyDir: {}
    

    The tomcat container runs the app, while logstash-forwarder forwards tomcat logs.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.