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

  • How run Docker with sync folder on Windows
  • Unable to connect to Elasticsearch with PHP inside Docker
  • Dockerizing nginx and Flask
  • Docker container is unable to connect to port opened by another docker container
  • Pull all images with specific tag from repository
  • Push docker image to remote server
  • 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.

  • docker volume driver: unable to override existing file
  • Running private_pub with docker
  • Difference between environment in Dockerfile RUN and interactive shell on a running container?
  • Http2 protocol in an nginx reverse proxy and docker container
  • Supervisord does not show stdout from processes
  • No connection to generic driver
  • 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
      name: tomcat
        app: tomcat
      replicas: 1
            app: tomcat
          - name: tomcat
            image: tomcat
            - name: tomcat-logs
              mountPath: /tomcat/log
              readOnly: false
          - name: logstash-forwarder
            image: apopelo/logstash-forwarder
            - name: tomcat-logs
              mountPath: /var/log/tomcat
              readOnly: true
          - 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.