moby: Very frequently getting zombie processes from killed Docker containers

I am running Ubuntu 14.04 with kernel version:

Linux execute 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

My kernel has the patch described here as fixing the longstanding zombie issue with Docker: http://stackoverflow.com/a/22600096/638592

My containers all basically are bash scripts that run some sort of TTY process (like ruby or python shell, for instance). I have no problems killing the container, but these processes stick around. This happens very reliably, but I’m not sure how to make a more minimally reproducing test case.

Can anyone advise me on how to get to the bottom of this?

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 32 (31 by maintainers)

Commits related to this issue

Most upvoted comments

@crosbymichael @unclejack

I am having my boy @hwong make a repro case in Go as an exercise. In the meantime, I also made the nodeJS repro case easier for you. It’s hard to give you an image because setting up docker-in-docker is a pain in my ass.

Instructions

  1. (Make sure you’ve pulled ubuntu:12.04 and that your current user can hit Docker’s remote API over the usual socket)
  2. Do apt-get install nodejs Whatever your distro packages is probably fine. If you want the latest stable node, just add-apt-repository ppa:chris-lea/node.js first.
  3. Do npm install dockerode
  4. Save the following file to test.js and then do node test.js
var createContainer, docker, _i;

docker = new (require('dockerode'))({
  socketPath: '/var/run/docker.sock'
});

createContainer = function() {
  return docker.createContainer({
    Cmd: '/bin/bash',
    Image: 'ubuntu:12.04',
    OpenStdin: true,
    Tty: true
  }, function(err, container) {
    if (err) {
      return;
    }
    container.start(function() {});
    container.kill(function() {});
    return container.remove(function() {});
  });
};

for (_i = 1; _i <= 10; _i++) {
  createContainer();
}

At this point you should have:

  • no containers
  • an orphaned /bin/bash process running under the docker daemon

#yolo