重新加载docker日志记录配置,无需守护程序重新启动

时间:2018-03-12 13:42:48

标签: docker logging kubernetes

我有一些&运行kubernetes集群,可能会产生大量日志。 Kubernetes在docker之上运行,所以我认为我需要configure dockerd to rollout logs

我找到了dockerd的日志驱动程序的一些设置:

{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10k",
    "max-file": "2"
  }
}

如果停靠服务器重新启动,则会成功应用更改。

du /var/lib/docker/containers/container_hash/container_hash* -h

显示按块大小分割的日志文件。

但我不想重启守护进程,因此尝试使用以下命令重新加载配置:

sudo kill -SIGHUP $(pidof dockerd)

在syslog中我发现:

Mar 12 15:38:16 kso-gl dockerd[5331]: time="2018-03-12T15:38:16.446894155+02:00" level=info msg="Got signal to reload configuration, reloading fr
om: /etc/docker/daemon.json"

所以,我假设配置已重新加载。不幸的是它没有效果。即使是新的容器。 看起来与日志驱动程序相关的子系统会忽略配置重新加载。

1 个答案:

答案 0 :(得分:3)

不幸的是,似乎配置重新加载SIGHUP功能不支持所有配置选项。

https://docs.docker.com/v17.09/engine/reference/commandline/dockerd/#miscellaneous-options处的文档(请参阅“配置重载行为”部分)告诉我们,唯一可以通过这种方式重载的受支持的配置选项是:

The list of currently supported options that can be reconfigured is this:

debug: it changes the daemon to debug mode when set to true.
cluster-store: it reloads the discovery store with the new address.
cluster-store-opts: it uses the new options to reload the discovery store.
cluster-advertise: it modifies the address advertised after reloading.
labels: it replaces the daemon labels with a new set of labels.
live-restore: Enables keeping containers alive during daemon downtime.
max-concurrent-downloads: it updates the max concurrent downloads for each pull.
max-concurrent-uploads: it updates the max concurrent uploads for each push.
default-runtime: it updates the runtime to be used if not is specified at container creation. It defaults to “default” which is the runtime shipped with the official docker packages.
runtimes: it updates the list of available OCI runtimes that can be used to run containers
authorization-plugin: specifies the authorization plugins to use.
allow-nondistributable-artifacts: Replaces the set of registries to which the daemon will push nondistributable artifacts with a new set of registries.
insecure-registries: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon’s configuration are not in newly reloaded insecure resgitries, these existing ones will be removed from daemon’s config.
registry-mirrors: it replaces the daemon registry mirrors with a new set of registry mirrors. If some existing registry mirrors in daemon’s configuration are not in newly reloaded registry mirrors, these existing ones will be removed from daemon’s config.

如您所见,其中不包含log-driverlog-opts配置参数。

我目前不知道一种无需重新启动即可重新加载日志记录配置的方法。