title: Starting docker container using python script
body: <p>I would like to start the docker container from a python script. When i call the docker image through my code , i am unable to start the docker container</p>
  
  <pre><code>import subprocess
  import docker
  
  
  from subprocess import Popen, PIPE
  
  
  def kill_and_remove(ctr_name):
      for action in ('kill', 'rm'):
          p = Popen('docker %s %s' % (action, ctr_name), shell=True,
                    stdout=PIPE, stderr=PIPE)
          if p.wait() != 0:
              raise RuntimeError(p.stderr.read())
  
  
  def execute():
      ctr_name = 'sml/tools:8' # docker image file name
      p = Popen(['docker', 'run', '-v','/lib/modules:/lib/modules',
                 '--cap-add','NET_ADMIN','--name','o-9000','--restart',
                 'always', ctr_name ,'startup',' --base-port',
                 9000,' --orchestrator-integration-license',
                 ' --orchestrator-integration-license','jaVl7qdgLyxo6WRY5ykUTWNRl7Y8IzJxhRjEUpKCC9Q='
                 ,'--orchestrator-integration-mode'],
                stdin=PIPE)
      out = p.stdin.write('Something')
  
      if p.wait() == -20:  # Happens on timeout
  
          kill_and_remove(ctr_name)
  
      return out
  </code></pre>
  
  <p>following are docker container details for your reference</p>
  
  <pre><code>dev@dev-VirtualBox:sudo docker ps -a
  [sudo] password for dev: 
  CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS               NAMES
  79b3b9d215f3        sml/tools:8   "/home/loadtest/st..."   46 hours ago        Up 46 hours                             pcap_replay_192.168.212.131_9000_delay_dirty_1
  </code></pre>
  
  <p>Could some one suggest me why i could not start my container through my program</p>