Java leaves zombie processes

I have a docker image which executes a shell script that runs a series of Java programs.
I am finding that the script does not complete; on examination I find that one of the Java executables exited but is a zombie - the caller failed to reap the exit status.

I’ve simplified the scripts to a bare minimum and it’s consistently reproducible.

The script that’s executed when the container is:

for f in 1 2 3 4 5 6 7 8 9 10
echo do $f

/tmp/bar is very simple too:

java >> /tmp/j.out 2>&1

On startup the container never completes. It’s not consistent; the log may show that the first Java invocation was successful but it never gets through all 10. The same happens if I log on to the container using docker exec and run the script manually.

ps shows a java zombie, although what’s interesting is that unlike a normal Unix zombie the TIME field continues to increase.

root 1 0 0 01:23 ? 00:00:00 /bin/bash /tmp/
root 17 1 0 01:23 ? 00:00:00 /bin/bash /tmp/bar
root 18 17 99 01:23 ? 00:06:13 [java]
root 28 0 0 01:23 ? 00:00:00 sh
root 40 28 0 01:29 ? 00:00:00 ps -ef

Any advice?

How did you start the container?

docker run imagename from the quick start terminal.
Also ran it from kinematic - same result

Ok I’m still learning docker but since you asked for “any advice” here it is lol

You probably need the -d option for detached or -i for interactive (depending on how you want to run it)? I think I recall with no options it runs and quits/dies. If your stuff takes some time (which java always does) I’m thinking the container ends thus the zombie but I am guessing. So it’s “any Ideas” lol

I read and tried using their container.

I ran docker run --rm -t -i phusion/baseimage /sbin/my_init – bash -l

I connected to the container using docker exec, installed Java using apt-get install default-jre and executed java; no arguments, just called java from the shell. I got a zombie - never got the shell prompt back.

On closer examination I realized that the apt-get install hadn’t completed either

 root        40    33  0 18:45 ?        00:00:00 bash
 root        72    40  0 18:46 ?        00:00:22 apt-get install default-jre
 root      3620    72  0 18:51 pts/0    00:00:00 /usr/bin/dpkg --status-fd 21 --configure libelf1:amd64 libsystemd-daemon0:amd64 libapparmor1
 root      4656  3620  0 18:51 pts/0    00:00:00 /bin/bash /var/lib/dpkg/info/ca-certificates-java.postinst configure
 root      4670  4656 56 18:51 pts/0    00:20:25 [java] <defunct>

If it matters I’m running on a Mac, El Capitan, with VirtualBox 5.0.10 r104061 running boot2docker version 1.9.1 build a34a1d5 - the virtual machine has 4Gb RAM

Hey there, I experienced the same problem (on multiple different images), but all of them were using phusion/baseimage.

It looks like the fix is included in the 0.9.18 release:

(docker forums not letting me post the link)