title: How to use MySQL and Flask-PonyORM App with docker-compose?
body: <p>I'm having a trouble on how to configure my application to integrate Flask, PonyORM, and MySQL using docker and docker-compose.</p>
  
  <p>This is my <code>.yml</code> file:</p>
  
  <pre><code>version: '3.1'
  services:
    mysql:
      image: mysql
      restart: always
      ports:
        - 3306:3306
      environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: kofre.db
  
    adminer:
      image: adminer
      restart: always
      ports:
        - 8080:8080
  
    python:
      build: .
      volumes:
        - .:/kofre-app
      ports:
        - 5000:5000
      depends_on:
        - mysql
  </code></pre>
  
  <p>This is my Dockerfile:</p>
  
  <pre><code>FROM python:3
  ENV PYTHONBUFFERED 1
  
  RUN mkdir /kofre-app
  
  WORKDIR /kofre-app
  
  COPY setup.py /kofre-app/
  RUN python setup.py install
  
  COPY . /kofre-app/
  
  CMD [ "python", "./run.py" ]
  </code></pre>
  
  <p>and this is a part of my Pony initialization script:</p>
  
  <pre><code>app = Flask(__name__)
  app.config.from_object('config')
  
  db = Database()
  db.bind(provider = 'mysql', host = 'mysql', user = 'root', passwd = 'root', db = 'kofre.db')
  </code></pre>
  
  <p>My problems: </p>
  
  <ol>
  <li>Sometimes when I run the command <code>docker-compose up</code> I'm getting the message: "Can't connect to MySQL server on 'mysql' (timed out)". Is it a proble with PonyORM? Should I use another framework?</li>
  <li>And sometimes, the <code>mysql</code> service seems to lock the prompt and nothing happens after that.</li>
  </ol>
  
  <p>Could someone help me with this problems? I'd appreciate your help.</p>