title: How to access and run command on host from Docker container?
body: <p>I want to access my host bash from Docker container and run there <em>netstat</em>, then get result of netstat and render it with Python/Flask as HTML page. Here is an example how i've done it without docker container.</p>
  
  <pre><code>from flask import Flask, render_template
  
  app = Flask(__name__)
  
  def get_ports_data():
      import subprocess
      p = subprocess.Popen(['netstat', '-ltup'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      stdout, stderr = p.communicate()
      data = stdout.decode().split('\n')
      return data
  
  @app.route('/')
  def index():
      return render_template('index.html', portsdata=get_ports_data())
  
  if __name__ == '__main__':
      app.run(debug=True,host='0.0.0.0')
  </code></pre>
  
  <p>It works great, but when i run it as a docker container i face a problem with accessing my host to run netstat and get a result. How can i do this?</p>