You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here we need to restart the docker daemon and everything is back to normal. Is there a memory leak? I see there is enough memory available. Is it because of the swap?
environment information
# top
top - 16:13:01 up 22 days, 7:56, 1 user, load average: 6.50, 5.44, 4.58
Tasks: 186 total, 3 running, 183 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni, 14.2%id, 1.3%wa, 33.7%hi, 0.0%si, 50.8%st
Mem: 4051204k total, 3886188k used, 165016k free, 3168k buffers
Swap: 0k total, 0k used, 0k free, 1681572k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20318 root 20 0 3449m 1.3g 10m S 0 34.0 18:27.87 docker
# memory stats
$ free
total used free shared buffers cached
Mem: 4051204 3884208 166996 0 3168 1681744
-/+ buffers/cache: 2199296 1851908
Swap: 0 0 0
# coreos version
$ cat /etc/lsb-release
DISTRIB_ID=CoreOS
DISTRIB_RELEASE=410.0.0
DISTRIB_CODENAME="Red Dog"
DISTRIB_DESCRIPTION="CoreOS 410.0.0"# docker info
$ docker info
Containers: 22
Images: 332
Storage Driver: btrfs
Execution Driver: native-0.2
Kernel Version: 3.15.8+
# docker version
$ docker -v
Docker version 1.1.2, build d84a070
I think that the error here is because of the kernel prevents the go runtime from allocating more memory. Setting up a swap does help in this case ( i think it should be possible in coreos to setup a swap ).
If it's possible, you can also test the latest 1.3 since it does have lots of improvements on memory allocations.
I'm experiencing the exact same behavior.
Starting and removing many short-lived containers, the virtual memory after 24h is up from ~300MB to aroung 1.5GB
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2762 root 20 0 1532596 22976 11220 S 0.0 0.6 1:28.18 docker
top - 19:19:33 up 24 days, 3:49, 1 user, load average: 1.30, 1.24, 1.16
Tasks: 203 total, 1 running, 201 sleeping, 0 stopped, 1 zombie
%Cpu(s): 9.7 us, 6.0 sy, 0.0 ni, 75.9 id, 7.1 wa, 1.0 hi, 0.2 si, 0.2 st
KiB Mem: 4051192 total, 3913096 used, 138096 free, 140 buffers
KiB Swap: 0 total, 0 used, 0 free. 187052 cached Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
28124 root 20 0 6618932 2.950g 9808 S 2.0 76.4 23:33.32 docker
The really crazy thing is docker --debug info's output. There are only 21 containers, but 2257 goroutines! This looks really really weird and feels like there are a lot of goroutines not cleaned up correctly.
lsof | wc -l says there are 841 open file descriptors. Docker seems to use 514 of them.
For us it looks like the hosts memory has nothing to do with that problem, since the docker daemon always frags on another limit. It looks more likely like the daemon is getting into a unrecoverable state at some point where it cannot handle the whole container management any more. This is maybe caused by spooky goroutines. I am just thinking loud. Maybe somebody has other ideas?
To get more and better information regarding this issue next time, which information would be cool to have to solve this problem quickly?
@denderello I'm curious -- do you make use of sidekicks that do docker inspect to determine the open ports of your containers? Experiencing similar problem to you on CoreOS, and I've got a hunch its related to our sidekicks. Going to run a test in our staging over the weekend to learn more.
@rosskukulinski: Yes, we are using sidekicks and I just had a look on how we are doing port inspection. Our approach is a bit different but could hit the same issue. Our sidekicks use docker port to determine open ports of other containers. Have you been able to run your tests?
Hello @denderello. I just checked in on our staging infrastructure and we had zero memory leaks over the weekend (yay!).
Unfortunately for you, it seems that issue was not with our sidekicks, but rather our configuration of Logstash / Elastic Search. We are running a logstash global unit gathering log files from each host, shipping through redis, to another logstash for processing and archival into elastic search. On Friday I stopped those services and cycled a reboot of the cluster to start fresh. Memory utilization remained unchanged since friday afternoon when before memory use was constantly increasing.
I'm not sure which piece of the ELK stack was causing our Docker daemons to consume all the memory, but we'll be digging into that tomorrow.
Cool that you could solve it in your cluster. I think we will have to go down the path of shutting down instances and take a look if maybe one specific container is causing the problems.
If anyone else has a hint we are happy to try it out. :)
@denderello@rosskukulinski does the application output a lot of logs to journalctl and/or any other log processor ( i assume that since you use coreos ) ?
No, mostly the daemon logging that containers are stopping and starting. Already checked with journalctl --disk-usage on the nodes which looks ok. Why are you asking? Experienced any problems with large journals?
@denderello docker does some log buffering internally, so i observed that when the container output more logs than the consumer can consume at a time ( the easiest way would be to run yes "long string" command as an docker unit, the daemon memory consumption can increase quite a bit.
I'm having the same problem I think. Even without having any containers running I still get the "fork/exec /sbin/iptables: cannot allocate memory)" maybe worth mentioning I'm running docker on ARM so I have only limited memory resources to my disposal. But still I am not hitting any limits yet so it seems rather strange. Oh and my docker version is 1.3.0
@jonathanperret good to know, logging will soon be resolved, thank you. This doesn't explain why in some rare cases dockerd returns memory to the system while application writing into log is still relatively active, and also what happened in the case where fork failed: it took resident memory when logging container is active
@bioothod As soon as your application writes a \n, the (1.12) log driver can write out the accumulated data and release the memory to the Go runtime; however it may take some time (seconds to minutes) for the Go runtime to release the memory to the OS, making it difficult to correlate memory usage reductions with various events such as a container exiting.
I'm not completely sure I understand what's puzzling you in the other case (…what happened in the case where fork failed: it took resident memory when logging container is active…): how much memory is resident out of the entire memory allocated by the daemon at any point in time, depends on various factors such as how recently it was accessed and the memory pressure from other processes on the box. It does not affect the (in)ability to fork.
Closing this as the original problem of not capping the attach stream was fixed in #17877 (v1.10). There was still an issue with long log lines (#18057) that corresponds to report from @bioothod . Fix for that is in master (#22982). I've added it to 1.12.2 milestone in case there will be one.
@thaJeztah It's a bug that massively affects the scalability of Docker (it drastically limits the number of containers running on a server). Your call though.
Is this even fixed in 1.13? I'm seeing some interesting memory creeps and then eventually I start seeing docker top start to fail with the fork/exec error. I'm still trying to figure out where the memory creep is at.
@ekristen There is a series of issues within the Go runtime that can cause your memory overcommit to go to very high levels, causing OOM to kill your process (even though it isn't actually using any of the memory). Maybe that's what causing the issue? Docker has pprof endpoints to get pprof output, so you could try investigating those.
@wsilvan That's because restarting a process will result in getting a new address space (without any of the funky pages that the Go runtime lazy allocates). Restarting Docker will "fix" the issue, but reloading all of the containers might also drive up memory usage (causing the same issue to happen again).
Activity
dqminh commentedon Oct 14, 2014
I think that the error here is because of the kernel prevents the go runtime from allocating more memory. Setting up a swap does help in this case ( i think it should be possible in coreos to setup a swap ).
If it's possible, you can also test the latest 1.3 since it does have lots of improvements on memory allocations.
n0rad commentedon Oct 20, 2014
Same here after a full day starting / stopping / rm containers on archlinux.
Far from full memory :
But docker virtual memory is huge and close to my max memory :
haches commentedon Oct 26, 2014
I'm experiencing the exact same behavior.
Starting and removing many short-lived containers, the virtual memory after 24h is up from ~300MB to aroung 1.5GB
on Ubuntu 14.04
malagant commentedon Oct 26, 2014
Same here. Docker 1.3.0
rosskukulinski commentedon Oct 26, 2014
also seeing what I believe to be the same issue on CoreOS 444.5.0 w/ Docker 1.2
rafikk commentedon Nov 5, 2014
+1 on Docker 1.3.1
denderello commentedon Nov 14, 2014
We have coreos cluster running and experience one outage once a week. Containers started through systemd unit files throw errors like this.
Further we are getting sometimes errors like this.
2014/11/10 19:17:00 Error response from daemon: Cannot start container 982f7a3da2dc182b61b1004d436a2cf68674ef949ab9848d4009c79094b3e592: iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 49298 ! -i docker0 -j DNAT --to-destination 172.17.1.173:6379: (fork/exec /usr/sbin/iptables: cannot allocate memory)topoutput looks like this.The really crazy thing is
docker --debug info's output. There are only 21 containers, but 2257 goroutines! This looks really really weird and feels like there are a lot of goroutines not cleaned up correctly.lsof | wc -lsays there are 841 open file descriptors. Docker seems to use 514 of them.For us it looks like the hosts memory has nothing to do with that problem, since the docker daemon always frags on another limit. It looks more likely like the daemon is getting into a unrecoverable state at some point where it cannot handle the whole container management any more. This is maybe caused by spooky goroutines. I am just thinking loud. Maybe somebody has other ideas?
To get more and better information regarding this issue next time, which information would be cool to have to solve this problem quickly?
rosskukulinski commentedon Nov 14, 2014
@denderello I'm curious -- do you make use of sidekicks that do
docker inspectto determine the open ports of your containers? Experiencing similar problem to you on CoreOS, and I've got a hunch its related to our sidekicks. Going to run a test in our staging over the weekend to learn more.denderello commentedon Nov 17, 2014
@rosskukulinski: Yes, we are using sidekicks and I just had a look on how we are doing port inspection. Our approach is a bit different but could hit the same issue. Our sidekicks use
docker portto determine open ports of other containers. Have you been able to run your tests?rosskukulinski commentedon Nov 17, 2014
Hello @denderello. I just checked in on our staging infrastructure and we had zero memory leaks over the weekend (yay!).
Unfortunately for you, it seems that issue was not with our sidekicks, but rather our configuration of Logstash / Elastic Search. We are running a logstash global unit gathering log files from each host, shipping through redis, to another logstash for processing and archival into elastic search. On Friday I stopped those services and cycled a reboot of the cluster to start fresh. Memory utilization remained unchanged since friday afternoon when before memory use was constantly increasing.
I'm not sure which piece of the ELK stack was causing our Docker daemons to consume all the memory, but we'll be digging into that tomorrow.
denderello commentedon Nov 18, 2014
Cool that you could solve it in your cluster. I think we will have to go down the path of shutting down instances and take a look if maybe one specific container is causing the problems.
If anyone else has a hint we are happy to try it out. :)
dqminh commentedon Nov 19, 2014
@denderello @rosskukulinski does the application output a lot of logs to journalctl and/or any other log processor ( i assume that since you use coreos ) ?
denderello commentedon Nov 21, 2014
No, mostly the daemon logging that containers are stopping and starting. Already checked with
journalctl --disk-usageon the nodes which looks ok. Why are you asking? Experienced any problems with large journals?dqminh commentedon Nov 21, 2014
@denderello docker does some log buffering internally, so i observed that when the container output more logs than the consumer can consume at a time ( the easiest way would be to run
yes "long string"command as an docker unit, the daemon memory consumption can increase quite a bit.calmera commentedon Nov 30, 2014
I'm having the same problem I think. Even without having any containers running I still get the "fork/exec /sbin/iptables: cannot allocate memory)" maybe worth mentioning I'm running docker on ARM so I have only limited memory resources to my disposal. But still I am not hitting any limits yet so it seems rather strange. Oh and my docker version is 1.3.0
108 remaining items
mlaventure commentedon Sep 2, 2016
@jonathanperret yes, bad tab completion 😅
bioothod commentedon Sep 2, 2016
@jonathanperret good to know, logging will soon be resolved, thank you. This doesn't explain why in some rare cases dockerd returns memory to the system while application writing into log is still relatively active, and also what happened in the case where fork failed: it took resident memory when logging container is active
jonathanperret commentedon Sep 2, 2016
@bioothod As soon as your application writes a
\n, the (1.12) log driver can write out the accumulated data and release the memory to the Go runtime; however it may take some time (seconds to minutes) for the Go runtime to release the memory to the OS, making it difficult to correlate memory usage reductions with various events such as a container exiting.I'm not completely sure I understand what's puzzling you in the other case (…what happened in the case where fork failed: it took resident memory when logging container is active…): how much memory is resident out of the entire memory allocated by the daemon at any point in time, depends on various factors such as how recently it was accessed and the memory pressure from other processes on the box. It does not affect the (in)ability to
fork.tonistiigi commentedon Sep 2, 2016
Closing this as the original problem of not capping the attach stream was fixed in #17877 (v1.10). There was still an issue with long log lines (#18057) that corresponds to report from @bioothod . Fix for that is in master (#22982). I've added it to 1.12.2 milestone in case there will be one.
Thanks for all the help @jonathanperret !
stszap commentedon Oct 24, 2016
@tonistiigi was the fix included in 1.12.2? I can still reproduce the problem in 1.12.2
mlaventure commentedon Oct 24, 2016
@stszap it looks like it didn't make it into 1.12.2
ping @vieux @thaJeztah is this a good candidate for 1.12.3? (Is there even enough time left to add it?)
thaJeztah commentedon Oct 24, 2016
@mlaventure @stszap we discussed cherry-picking that PR into a patch release for 1.12, but decided to keep it for 1.13 as it's not a regression in 1.12
cyphar commentedon Oct 25, 2016
@thaJeztah It's a bug that massively affects the scalability of Docker (it drastically limits the number of containers running on a server). Your call though.
jmreicha commentedon Nov 28, 2016
@thaJeztah When is 1.13 scheduled to be released? What is the workaround until then?
ekristen commentedon Jan 26, 2017
Is this even fixed in 1.13? I'm seeing some interesting memory creeps and then eventually I start seeing docker top start to fail with the fork/exec error. I'm still trying to figure out where the memory creep is at.
cyphar commentedon Jan 26, 2017
@ekristen There is a series of issues within the Go runtime that can cause your memory overcommit to go to very high levels, causing OOM to kill your process (even though it isn't actually using any of the memory). Maybe that's what causing the issue? Docker has
pprofendpoints to getpprofoutput, so you could try investigating those.wsilvan commentedon Jan 28, 2017
This error has been resolved after restart of docker daemon. It's works for me, but is intermittent
cyphar commentedon Jan 29, 2017
@wsilvan That's because restarting a process will result in getting a new address space (without any of the funky pages that the Go runtime lazy allocates). Restarting Docker will "fix" the issue, but reloading all of the containers might also drive up memory usage (causing the same issue to happen again).
lpcclown commentedon Jan 29, 2018
This error has been resolved after restart of docker daemon.
The commands are:
sudo service docker stop
sudo service docker start