title: Cron job to execute a Flask/Python function inside a docker container?
body: <p>I would like to use a cron job outside a docker container to execute a Python/Flask function inside a docker container. </p>
  
  <p>Is it possible to do so? </p>
  
  <p>Just doing a <code>docker exec</code> doesn't do so, I believe Flask might have some limitations with allowing access to functions. </p>
  
  <p>Or is there a better alternative? </p>
  
  <p>Here is a sample code in <code>main.py</code>
  I would like the cron job to execute <code>getThisFunction()</code> in main.py that is running in a docker container </p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  
  @app.route('/')
  def hello():
          return "Hello World!"
  
  @routes.route('/getThisFunction', methods=['GET', 'POST'])
  def getThisFunction():
      return "foobar"
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>I would like a cron job like below (not exactly similar):</p>
  
  <p><code>26 08 * * * docker exec c78ddbed4ad9 {some stuff to execute getThisFunction() in main.py}</code></p>