Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

docker: "fatal error: runtime: out of memory" when container produces lots of logs #908

Closed
kayrus opened this issue Oct 6, 2015 · 9 comments

Comments

@kayrus
Copy link

kayrus commented Oct 6, 2015

Reproducible in 647.0.0, 723.3.0 and 815.0.0

Use this test systemd unit:

[Unit]
Description=MyApp
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill busybox1
ExecStartPre=-/usr/bin/docker rm busybox1
ExecStartPre=/usr/bin/docker pull busybox
ExecStart=/usr/bin/docker run --name busybox1 busybox /bin/sh -c 'while true; do echo "ANEP5iXIZOC/7Ta5jit8YQTXBnCzLPQYPsv5nXsjxfla1YEHgSG5F7tgGaBPA2g5SIhOMacfqVgW\
IrQyQ69OEoSj5KWNOKY+IDARNb3LBtuLnnD4s9FeXwS/6JOX3/b9IIuJMjVXsoWPgTs4T0yqNfDu\
pFPUjH/YJwVwCzwiFP4RQmq1F37eVcITQHlnlGOtzezqX8a4gdVK4C7sAR8Cou5/WZYtu0Zo0Vip\
M6O92bwx2j4JGQ1RevDZu8gAuaikxiWlyRYqhcXratEvwNThfxoJF5epvXEjWaXUIo0opPXxWTJD\
5omO4vYYgh9LprCGbxFH7OtCZ0agdqBeOZf4Taky85MRl42zTEvhWp9XO6Oj9dcE+P4GOzDuCVZg\
bPSKZis8xN5eBlJo+lzrvD/c3FVCFg/05/2PcemiZNmMKngG8dbiiEOrHiCXIRGbLaRFvMckUDOK\
ZnFC1liROZYwrx8pthtMnsMpovik3AggfX3RouihySlDmNU7aUwgCZAIjIhOVYgkPcG9Q/TFs27v\
YnQn3y4lF1UsHLShqrFPSrs1t23+sG/qcNbQLqBRm1iJqCIHaDIuiuNDeIJTLejPTHL4pIeGNrky\
BXmZ5bV/OL1B6IvJntl/Fd/UMdwI07EDVgpYpAg1FGRkLBhQGlBpX+hAbOHoGj381mpVhbwEhsp1\
7CJQAolcfjLBD32W9oPQ9zhLpMj4T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7Vfbk8Gg+DqtzQFfKcECDFXcNsf7D5kY/we874mAnGCjlmuOhwGyLKgdSynN3e374g/d\
vxnaThUaqCO07K5b4BqDrd9HWXKmtgadxZt6EhXIEYJNeW/Hl9HYcKz4z1NQ76qiqIqbsDSZdMjx\
yxVfNlUt96YqvJmTgOUK5ooPSSYfNYgZszwG6RXSPBqFMQluW04KO61CTkM2qOn7uPYcXThpIn09\
FzyuA0Y1r7VTy6rx+Gs0KkpO1PvckTMHftT98tLSBQPkGEr5sqz1Q8zmDNLrY89VM64QJRDNCnuU"; done'
ExecStop=/usr/bin/docker stop busybox1

Run it and you'll receive fatal error: runtime: out of memory error message

/cc @philips @crawford

UPDATE: weird... busybox+sh fails docker container. ubuntu+sh fails container. ubuntu+bash - not.
UPDATE1: increased burst and rate interval (RateLimitInterval=120s and RateLimitBurst=10000) produces same docker issue even with ubuntu container + bash.

@dongsupark
Copy link

I can also easily see this error, with docker 1.8.2, kernel 4.3-rc4 on a virtual machine with 1G RAM.
I suppose it's a similar issue as moby/moby#14460. However, with docker 1.8.2 the crash seems to still happen.
As a workaround, it would be possible to raise system memory to 2G or higher. That'll work according to my tests.
In contrast to other issues like #489, it's interesting that kernel OOM killer is not necessarily involved in this case. So it might make sense to limit memory utilization on the docker side.

@dongsupark
Copy link

Docker 1.9.0-dev 52de250 (current master) seems to be a little different from 1.8.2. Now with 1.9.0-dev the dockerd process doesn't die immediately on the internal buffer, but it runs for a while, until the kernel oom-killer actually kills that daemon.

@dongsupark
Copy link

I think we can close this issue, as the problem was already solved by moby/moby#16190, which reimplements NewBufReader(). See also https://github.com/LK4D4/docker/commit/24310b5b4ab600ab5cb046d2f2ceaaa086b30be3 and https://github.com/LK4D4/docker/commit/56b70bf84e253bfedef94248a0b6b1f8d730091c.
With those changes, docker daemon effectively introduces a maximum limit to the internal buffer, making use of a new type BytesPipe. That looks good to me.
All we should do with this issue is waiting for the next release of docker 1.9.

@kayrus kayrus closed this as completed Oct 9, 2015
@jonathanperret
Copy link

I would be careful closing this. The reason moby/moby@52de250 behaves differently, is that it includes moby/moby#16190 . However, as @dongsupark witnessed, it still allocates unlimited memory (the internal buffer is not capped even after moby/moby#16190 , despite appearances ) when logging faster than logs are consumed.

@vcaputo
Copy link

vcaputo commented Nov 10, 2015

There's a new PR up re: bounded buffer: moby/moby#17877

@chr0n1x
Copy link

chr0n1x commented Feb 3, 2016

bump & 👍

@mischief
Copy link

moby/moby#17877 is merged and is in 1.10.0. it could potentially be backported to 1.9.1. i was not able to reproduce this problem on coreos 983.0.0.

@jonathanperret
Copy link

moby/moby#17877 should definitely prevent this issue, indeed.

@crawford
Copy link
Contributor

This should no longer be an issue now that a newer Docker is being shipped.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants