文档章节

error from daemon in stream: Error grabbing logs: invalid character 'l' after object key:value pair

雁南飞丶
 雁南飞丶
发布于 01/15 14:54
字数 373
阅读 34
收藏 0

Issue

While running docker container logs you see errors such as this:

error from daemon in stream: Error grabbing logs: invalid character 'l' after object key:value pair

or:

Error streaming logs: invalid character 'e' in string escape code

where the more general format is:

Error streaming logs: invalid character

followed by a single character delimited by single quotes, followed by (but not necessarily limited to) one of:

  • after object key:value pair
  • after object key
  • in string escape code
  • looking for beginning of value

Prerequisites

Before performing these steps, you must meet the following requirements:

Root Cause

The cause appears to be most likely the result of an ungraceful shutdown, corrupting one or more container log files. When the container is started back up (eg, after an OS reboot), the engine's JSON log file parser is at odds with the contents of the logfile, resulting in the reported errors.

Resolution

Rather than attempt to reconstruct the corrupted logs, the best and quickest approach to recovery is as follows:

  1. Identify the corrupted files (as root):

    for FILE in /var/lib/docker/containers/*/*-json.log
    do
        jq '.' $FILE >/dev/null || echo "CORRUPT: $FILE"
    done
    
  2. Stop the engine:

    systemctl stop docker
    

    or

    service docker stop
    

    depending on your OS.

  3. (Optional) Make a backup copy of the corrupted log files (as reported by the script above).

    Be mindful of the size of the log file vs the remaining partition free space.

  4. Zero out the corrupted log files by executing the following for each corrupted log file:

    cat /dev/null > /path/to/corrupted/logfile
    
  5. (Optional) Set json-file log limits in /etc/docker/daemon.json. For example:

    {
      "log-driver": "json-file",
      "log-opts": {"max-size": "10m", "max-file": "3"}
    }
    
  6. Start the engine:

    systemctl start docker
    

    or

    service docker start
    

    depending on your OS.

Additional Info

The script above uses jq, a lightweight and flexible command-line JSON processor. Installable packages are available.

© 著作权归作者所有

雁南飞丶
粉丝 37
博文 176
码字总数 228466
作品 0
西安
运维
私信 提问
PHP 7.2.0 发布

PHP 7.2.0正式版发布日期 30 Nov 2017 BCMath: Fixed bug #46564 (bcmod truncates fractionals). CLI: Fixed bug #74849 (Process is started as interactive shell in PhpStorm). Fixed b......

michealz
2017/12/06
0
0
Nginx源码分析系列2:系统错误提示信息汇总

error no.0---Success error no.1---Operation not permitted error no.2---No such file or directory error no.3---No such process error no.4---Interrupted system call error no.5---I......

强子哥哥
2013/12/07
0
1
get_s等secure functions的使用

s类函数的使用策略 首先介绍下getss、getwss函数的用法。getss, getwss https://msdn.microsoft.com/en-us/library/5b5x9wc7.aspx Gets a line from the stdin stream. These versions of g......

zray4u
2016/07/01
4
0
创建calico网络报错client response is invalid json

使用docker创建calico网络失败。 查看docker日志: 首先想到的错误原因可能是:calico网络后台的分布式存储是etcd,而环境中使用的V3版本的etcd,而该版本在API方面既支持V2又支持V3。docke...

BookShu
2018/06/14
0
0
FLVTool2

FLVTool2是用来操作 FLV 的工具 其命令格式:flvtool2.exe [-ACDPUVaciklnoprstvx]... [-key:value]... in-path|stdin [out-path|stdout] 如果out-path未定义,则将覆盖原文件,如果指定in-...

匿名
2008/11/13
5.7K
0

没有更多内容

加载失败,请刷新页面

加载更多

抽象同步队列AQS——AbstractQueuedSynchronizer锁详解

AQS——锁的底层支持 谈到并发,不得不谈ReentrantLock;而谈到ReentrantLock,不得不谈AbstractQueuedSynchronizer(AQS)! 类如其名,抽象的队列式的同步器,AQS定义了一套多线程访问共享资...

须臾之余
今天
3
0
springboot配置百度UEditor 富文本详解

富文本简介 UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码... 准备工作 ueditor需要单独文...

wotrd
昨天
4
0
mysql 5.7之my.cnf配置大全

[client]port = 3306socket = /tmp/mysql.sock[mysqld]###############################基础设置######################################Mysql服务的唯一编号 每个mysql服务...

Online_Reus
昨天
3
0
MAVEN打包时引入外部链接的包

1.项目引入了ORACLE的jar包,MAVEN配置如下 2.打jar包的时候需要指定下main入口函数mainClass <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> ......

Cobbage
昨天
3
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部