moby: Docker logs crashes every couple of hours
Description
Every couple of hours docker compose logs crashes on my production server. In the system logs (/var/log/docker) I find something like this:
error unmarshalling log entry (size=108554): proto: LogEntry: illegal tag 0 (wire type 6)
This error is then followed by several errors that the log message is too large:
Error streaming logs: log message is too large (1937007727 > 1000000)
Note that the too large log message in this case is almost 2GB!
Manually running something like this also triggers the log message is too large error:
sudo docker logs abc123 --since "2023-10-16T18:49:10" --until "2023-10-16T18:50:00"
The environment
I am encountering this issue on two different production environments, both running on AWS EC2 instances:
- A Kong API gateway, which is an application built on top of nginx. It is third party software, we did not write code for this
- Our own node.js application, that runs in a container but has a separate nginx container running next to it
Both seem to fail on the access logs. The kong gateway crashes every couple of hours, while the environment running our nodejs application crashes about once a week. We use the docker awslog driver to send the logs to cloudwatch. Cloudwatch seems to receive all logs, while manually running docker logs seems to miss up to multiple hours of logs every time after the error occurs.
What I have tried
- I have looked into the cloudwatch logs for ‘weird’ log entries at the time of the error, and I have particularly looked for big log entries or weird characters but could not find any.
- I ran docker logs manually in an open ssh session, which results in the same error as reported in the system logs
- I have downloaded the cached log files and went through them using less, tail and other tools. Doing this I found out that the cached logs misses entries that do exist in Cloudwatch
- I’ve tried copying these logs and make them available in a dummy container, so I have a more ‘stable’ environment to figure out the bug, but I cant get it to work
Reproduce
I have tried to get a reproducible situation, but I am unable to do so. I cannot pinpoint the log that crashes the system, nor can I import cached logs in another container. But this is my situation:
- Run an application with nginx (this is quite an assumption)
- Log a lot of access logs
- Have the application crash
Expected behavior
Docker logs should not crash
docker version
Client:
Version: 20.10.23
API version: 1.41
Go version: go1.18.9
Git commit: 7155243
Built: Tue Apr 11 22:56:36 2023
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.23
API version: 1.41 (minimum version 1.12)
Go version: go1.18.9
Git commit: 6051f14
Built: Tue Apr 11 22:57:17 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.19
GitCommit: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
runc:
Version: 1.1.7
GitCommit: f19387a6bec4944c770f7668ab51c4348d9c2f38
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc., 0.0.0+unknown)
compose: Docker Compose (Docker Inc., v2.22.0)
Server:
Containers: 3
Running: 3
Paused: 0
Stopped: 0
Images: 3
Server Version: 20.10.23
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 1e1ea6e986c6c86565bc33d52e34b81b3e2bc71f
runc version: f19387a6bec4944c770f7668ab51c4348d9c2f38
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 4.14.326-245.539.amzn2.x86_64
Operating System: Amazon Linux 2
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.781GiB
Name: ip-172-31-17-252.eu-west-1.compute.internal
ID: 5ELM:KYZM:7AEB:RH2I:FFL6:G2SA:4OOR:SGWE:6JOC:NXBS:U7HA:HA3Y
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Additional Info
I am aware I have not much info to go on, since I am not capable of providing reproducible steps. I can however access the production environment and execute debugging steps if this helps.
Note: I am sent here after creating an issue in the the docker cli repo. (https://github.com/docker/cli/issues/4617). The commenter over there suggests this version of docker might be maintained by AWS. I did indeed make a ticket with them, their (business tier) support however remains unresponsive.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 32 (6 by maintainers)
@wouthoekstra
After taking a further look, my theory is that this issue could be caused by unfitted encode/decode mechanism between
awsloglog driver andlocallog driver. As you mentioned, you configuredawslogdriver in your application and the log messages would be processed bycloudwatchlogs.gowhich works fine and all your logs are available in cloudwatch. However, sinceawslogdoes not providereadmethod for local logs reading, the dual logging would be kicked off by default. Your log entries would be cached to local machine and docker daemon would invokelocallogdriver to read when you hitdocker log(and when beanstalk executedocker compose logas well). As we can see inawslog, this log driver does not encode log entries with protocol buffer standard defined in moby but thelocaldriver would read local cached logs with the protocol buffer standard. This could be the cause oferror unmarshalling log entry (size=73482): proto: LogEntry: illegal tag 0 (wire type 6)and then this error could occur repeatedly and get stacked until the rate limit configured by Amazon Linux is reached then we see the other errorerror from daemon in stream: Error grabbing logs: log message is too large.Could you try the following steps as a walkaround?
awslogtolocal, this would help making sure the log encoding compliant with protocol buffer standard.logstreamingin Elastic Beanstalk, this would help uploading local logs to cloudwatch(CW) through beanstalk controlled path. And we should be able to see them in CW under/aws/elasticbeanstalk/environment_name/var/log/eb-docker/containers/eb-current-app/stdouterr.log.If this issue is gone after this walkaround, it would be a support of my hypothesis and we would be more clear on what is our next step.