How to Change Docker Logging Driver from journald to json-file
How to Change Docker Logging Driver from journald to json-file in centOS/RHEL ?
1. Check the current Docker Logging Driver.
[root@centos ~]# docker info --format '{{.LoggingDriver}}'
journald
[root@centos ~]#
2. Check the Daemon.json File.
[root@centos ~]# cat /etc/docker/daemon.json
{}
[root@centos ~]#
3. Check the docker file Inside "/etc/sysconfig" and chage the Log Driver option.
[root@centos ~]# cat /etc/sysconfig/docker.rpmsave
# /etc/sysconfig/docker
# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=json-file --signature-verification=false'
#OPTIONS='--selinux-enabled --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
4. Change the option in "--log-driver=json-file" in the File.
5. Do the Daemon Reload.
systemctl daemon-reload
6. Restart the Docker Service.
systemctl restart docker
7. If you get API connection refused Error, then do the server reboot.
reboot
8. Now Check the Docker logging Driver to see if the Changes has been Updated.
[root@centos ~]# docker info --format '{{.LoggingDriver}}'
json-file
[root@centos ~]#
Interesting Articles on Kubernetes:
Kubernetes : Kubernetes Node Management, Maintenance, Delete
How to add a New Worker Node to a existing kubernetes Cluster
MinIO Client Installation and Quickstart
PLEG is not healthy: Kubernetes Worker Node is in "NotReady" state
Backup MySQL databases in Kubernetes
How to Run Automated Tasks in Kubernetes with a cronjob
How to Completely remove Kubernetes
Kubernetes : Kubernetes Node Management, Maintenance, Delete
How to add a New Worker Node to a existing kubernetes Cluster
MinIO Client Installation and Quickstart
PLEG is not healthy: Kubernetes Worker Node is in "NotReady" state
Backup MySQL databases in Kubernetes
How to Run Automated Tasks in Kubernetes with a cronjob
How to Completely remove Kubernetes
To Check what is the Logging Driver a Particular Container is using?
To find the current logging driver for a running container, if the daemon is using the json-file logging driver, run the following docker inspect command, substituting the container name or ID for <CONTAINER>:
$ docker inspect -f '{{.HostConfig.LogConfig.Type}}' <CONTAINER>
[root@centos ~]# docker inspect -f '{{.HostConfig.LogConfig.Type}}' 9a3dfda01636
json-file
[root@centos ~]#
Supported logging drivers
The following logging drivers are supported.
Driver Description
none No logs are available for the container and docker logs does not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
local Writes logs messages to local filesystem in binary files using Protobuf.
syslog Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.
journald Writes log messages to journald. The journald daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to splunk using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.
Limitations of logging drivers:
The docker logs command is not available for drivers other than json-file and journald.
Reference for this document is taken from Docker official website.
No comments