Home
Softono

Docker Logger

Open source MIT Go
256
Stars
37
Forks
5
Issues
9
Watchers
2 months
Last Commit

 About Docker Logger

Logs collector for docker

Platforms

Web Self-hosted Docker

Languages

Go

Links

Need Help Installing Docker Logger?

We provide expert installation service for this software. Our team will install, configure, and secure Docker Logger on your server. plans start at just $30.

Docker Logger

View on GitHub

docker-logger Go Report Card Docker Hub

docker-logger is a small application collecting logs from other containers on the host that started without the -t option and configured with a logging driver that works with docker logs (journald and json-file). It can forward both stdout and stderr of containers to local, rotated files and/or to remote syslog.

note: dkll includes all functionality of docker-logger, but adds server and cli client

Install

Copy provided docker-compose.yml, customize if needed and run with docker-compose up -d. By default docker-logger will collect all logs from containers and put it to ./logs directory.

Customization

All changes can be done via container's environment in docker-compose.yml or with command line

Command line Environment Default Description
--docker DOCKER_HOST unix:///var/run/docker.sock docker host
--syslog-host SYSLOG_HOST 127.0.0.1:514 syslog remote host (udp4)
--files LOG_FILES No enable logging to files
--syslog LOG_SYSLOG No enable logging to syslog
--max-size MAX_SIZE 10 size of log triggering rotation (MB)
--max-files MAX_FILES 5 number of rotated files to retain
--mix-err MIX_ERR false send error to std output log file
--max-age MAX_AGE 30 maximum number of days to retain
--exclude EXCLUDE excluded container names, comma separated
--include INCLUDE only included container names, comma separated
--include-pattern INCLUDE_PATTERN only include container names matching a regex
--exclude-pattern EXCLUDE_PATTERN only exclude container names matching a regex
TIME_ZONE UTC time zone for container
--loc LOG_FILES_LOC logs log files location
--syslog-prefix SYSLOG_PREFIX docker/ syslog prefix
--json, -j JSON false output formatted as JSON
--dbg DEBUG false debug mode
  • at least one of destinations (files or syslog) should be allowed
  • location of log files can be mapped to host via volume, ex: - ./logs:/srv/logs (see docker-compose.yml)
  • both --exclude and --include flags are optional and mutually exclusive, i.e. if --exclude defined --include not allowed, and vice versa.
  • both --include and --include-pattern flags are optional and mutually exclusive, i.e. if --include defined --include-pattern not allowed, and vice versa.
  • both --exclude and --exclude-pattern flags are optional and mutually exclusive, i.e. if --exclude defined --exclude-pattern not allowed, and vice versa.
  • cross-kind combinations are also mutually exclusive: --include + --exclude-pattern, --include-pattern + --exclude, and --include-pattern + --exclude-pattern are not allowed.

Running as Non-Root

By default, the container runs as root because access to the Docker socket (/var/run/docker.sock) requires it on most systems. To run as a non-root user, set the following environment variables:

  • APP_UID — the user ID for the application process (e.g., 1001)
  • DOCKER_GID — the group ID that owns the Docker socket on the host

To find the Docker socket GID on the host, run:

stat -c '%g' /var/run/docker.sock

Then configure the container accordingly:

environment:
    - APP_UID=1001
    - DOCKER_GID=998  # use the value from the command above

Build from the Source

  • clone this repo - git clone https://github.com/umputun/docker-logger.git
  • build the logger - cd docker-logger && docker build -t umputun/docker-logger .
  • try it - docker run -it --rm -v $(pwd)/logs:/srv/logs -v /var/run/docker.sock:/var/run/docker.sock umputun/docker-logger /srv/docker-logger --files