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/*/

  • GitLab Runner reporting failed docker image build stage as passed
  • How can I enable MySQL binary logging using the official Docker image?
  • Unable to run shell script using dockerfile
  • Equivalent of --env-file for build-arg?
  • Cannot push to remote repo using the (spotify) Docker maven plugin
  • libgd not installed in php:5.6-cli docker
  • 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.

  • How to _directly_ COPY files to “Program Files (x86)” folder in a Windows container?
  • create a web2py docker image and access it through browser
  • How to do dynamic port mapping in docker and proxy?
  • Can't create Docker machine
  • Selenium Grid with Docker containers on different hosts
  • ECONNREFUSED nodeJS with express inside docker container
  • 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.