title: Install mysql in dockerfile?
body: <p>I want to write simple python application and put in docker conteiner with dockerfile. My dockerfile is:</p>
  
  <pre><code>FROM ubuntu:saucy
  
  # Install required packages
  RUN apt-get update
  RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python
  RUN DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server python-mysqldb
  
  # Add our python app code to the image
  RUN mkdir -p /app
  ADD . /app
  WORKDIR /app
  
  # Set the default command to execute
  CMD ["python", "main.py"]
  </code></pre>
  
  <p>In my python application I only want to connect to the database. main.py look something like this:</p>
  
  <pre><code>import MySQLdb as db
  
  connection = db.connect(
                  host='localhost',
                  port=3306,
                  user='root',
                  passwd='password',
              )
  </code></pre>
  
  <p>When I built docker image with:</p>
  
  <pre><code>docker build -t myapp .
  </code></pre>
  
  <p>and run docker image with:</p>
  
  <pre><code>docker run -i myapp
  </code></pre>
  
  <p>I got error:</p>
  
  <pre><code>_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
  </code></pre>
  
  <p>What is the problem?</p>