title: How to limit `docker run` execution time?
body: <p>I want to run a command inside a docker container. If the command takes more than 3 seconds to finish, the container should be deleted.</p>
  
  <p>I thought I can achieve this goal by using <code>--stop-timeout</code> option in <code>docker run</code>.</p>
  
  <p>But it looks like something goes wrong with my command. </p>
  
  <p>For example, <code>docker run -d --stop-timeout 3 ubuntu:14.04 sleep 100</code> command creates a docker container that lasts for more than 3 seconds. The container is not stopped or deleted after the 3rd second.</p>
  
  <p>Do I misunderstand the meaning of <code>--stop-timeout</code>?</p>
  
  <p>The <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="noreferrer">document</a> says </p>
  
  <blockquote>
    <p><code>--stop-timeout</code> Timeout (in seconds) to stop a container</p>
  </blockquote>
  
  <p>Here's my docker version:</p>
  
  <pre><code>Client:
   Version:       17.12.0-ce
   API version:   1.35
   Go version:    go1.9.2
   Git commit:    c97c6d6
   Built: Wed Dec 27 20:03:51 2017
   OS/Arch:       darwin/amd64
  
  Server:
   Engine:
    Version:      17.12.0-ce
    API version:  1.35 (minimum version 1.12)
    Go version:   go1.9.2
    Git commit:   c97c6d6
    Built:        Wed Dec 27 20:12:29 2017
    OS/Arch:      linux/amd64
    Experimental: true
  </code></pre>
  
  <p>The API version is newer than 1.25.</p>