title: Python MySQL connection lost inside Docker container
body: <p>I have a script that queries four separate MySQL databases (hosted elsewhere) using Python (with <code>mysql-connector==2.2.9</code>). I wrote and tested this script locally, and it runs without issue on my MacBook. I then created a Docker image using <code>ubuntu:18.04</code> as the base image, and would like to run this script inside the container. Starting the container locally, it queries the first DB without issue, but I get the following error on the second DB:</p>
  <p><code>mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query</code></p>
  <p>This <em>only</em> happens inside the container. The relevant code snippit:</p>
  <pre><code>for i, host in enumerate(hosts):
      cnx = mysql.connector.connect(user=os.environ[&quot;DBUSER&quot;],
                                    password=os.environ[&quot;DBPASSWORD&quot;],
                                    host=host,
                                    database=XXXXX
                                    )
      cursor = cnx.cursor()
      cursor.execute(query)
      df = pd.DataFrame(cursor.fetchall(), columns=columns)
  </code></pre>
  <p>Because the same code runs without issue outside of the container, I don't believe the issue is on the server. Additionally, most of the timeout parameters on the server seem fine. Querying <code>show session variables like '%timeout';</code> returns the following:</p>
  <pre><code>('delayed_insert_timeout', '300')
  ('have_statement_timeout', 'YES')
  ('innodb_flush_log_at_timeout', '1')
  ('innodb_lock_wait_timeout', '50')
  ('innodb_rollback_on_timeout', 'OFF')
  ('interactive_timeout', '7200')
  ('lock_wait_timeout', '31536000')
  ('net_read_timeout', '600')
  ('net_write_timeout', '600')
  ('rpl_stop_slave_timeout', '31536000')
  ('slave_net_timeout', '3600')
  ('thread_pool_idle_timeout', '60')
  ('wait_timeout', '7200')
  </code></pre>
  <p>Thanks for any help!</p>