In docker run --ulimit cpu=10 does not work in some cases
<p>I am having an weird issue using <code>--ulimit cpu=10</code>. I want to make sure the process gets killed after 10 seconds of using the CPU. When the java process is invoked directly it fails, but when it is invoked by first running bask it works.</p>

<p>This works fine.The process gets killed after 10s</p>

<pre><code>docker run --rm -i -v /usr/local/src:/classes --ulimit cpu=10 java:8 \
    bash -c 'java -cp /classes/ InfiniteLoop'
</code></pre>

<p>But this doesn't.</p>

<pre><code>docker run --rm -i -v /usr/local/src:/classes --ulimit cpu=10 java:8 \
    java -cp /classes/ InfiniteLoop
</code></pre>

<p>Any idea how to fix this issue?</p>