docker修改配置日志驱动程序,设置日志的大小
老版本的docker所使用的日志驱动程序是:journald,使用docker info能进行查看。我们要对docker上的容器的日志进行收集,需要将日志驱动程序修改为:json-file驱动,重启docker报错。1.查看下文件配置:[root@i-m7uysopv redis_exporter]# grep -v "^#" /etc/sysconfig/dockerOPTIONS='--sel
·
老版本的docker所使用的日志驱动程序是:journald,使用docker info能进行查看。我们要对docker上的容器的日志进行收集,需要将日志驱动程序修改为:json-file驱动,重启docker报错。
1.查看下文件配置:
[root@i-m7uysopv redis_exporter]# grep -v "^#" /etc/sysconfig/docker
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
2.修改配置文件/etc/docker/daemon.json
[root@i-m7uysopv redis_exporter]# cat /etc/docker/daemon.json
{
"insecure-registries":[
"registry:5000"
],
"log-opts": {"max-size":"10m", "max-file":"3"}
}
重启后出现docker异常。
[root@i-m7uysopv redis_exporter]# systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@i-m7uysopv redis_exporter]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2020-08-20 15:04:20 CST; 3s ago
Docs: http://docs.docker.com
Process: 16312 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/docker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 16312 (code=exited, status=1/FAILURE)
Aug 20 15:04:20 i-m7uysopv systemd[1]: Starting Docker Application Container Engine...
Aug 20 15:04:20 i-m7uysopv dockerd-current[16312]: Failed to set log opts: unknown log opt 'max-size' for journald log driver
Aug 20 15:04:20 i-m7uysopv systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Aug 20 15:04:20 i-m7uysopv systemd[1]: Failed to start Docker Application Container Engine.
Aug 20 15:04:20 i-m7uysopv systemd[1]: Unit docker.service entered failed state.
Aug 20 15:04:20 i-m7uysopv systemd[1]: docker.service failed.
3.修改Docker服务启动文件:
[root@i-m7uysopv redis_exporter]# grep -v "^#" /etc/sysconfig/docker
OPTIONS='--selinux-enabled --log-driver=json-file --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
DOCKER_CERT_PATH=/etc/docker
fi
4.在重启下docker
[root@i-m7uysopv redis_exporter]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2020-08-20 15:15:04 CST; 2s ago
Docs: http://docs.docker.com
Main PID: 19200 (dockerd-current)
Memory: 15.2M
CGroup: /system.slice/docker.service
├─19200 /usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/...
└─19206 /usr/bin/docker-containerd-current -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/contain...
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.305180741+08:00" level=warning msg="Docker could not enable SELinux on the host system"
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.310750545+08:00" level=info msg="Graph migration to content-addressability took 0.00 seconds"
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.312438045+08:00" level=info msg="Loading containers: start."
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.321522243+08:00" level=info msg="Firewalld running: false"
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.437320198+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon optio...d IP address"
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.474608708+08:00" level=info msg="Loading containers: done."
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.499092884+08:00" level=info msg="Daemon has completed initialization"
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.499127312+08:00" level=info msg="Docker daemon" commit="64e9980/1.13.1" graphdriver=overlay2 version=1.13.1
Aug 20 15:15:04 i-m7uysopv systemd[1]: Started Docker Application Container Engine.
Aug 20 15:15:04 i-m7uysopv dockerd-current[19200]: time="2020-08-20T15:15:04.516506905+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
更多推荐
已为社区贡献1条内容
所有评论(0)