...

/

Running the Database Container

Running the Database Container

The awaited database integration to our app.

In this lesson, we will add a database container to our app. We will use the MySQL server version 5.7 because it is the most used version of MySQL server.

Steps to add the database

  • Pull MySQL server’s official Docker Hub image

  • Run the image with MySQL environment variables

  • Install the DB connector for the flask

  • Change the application code

  • Run the Flask app with a link to the database container

We will study all the steps above in detail below.

MySQL image

Type docker pull mysql/mysql-server:5.7 to pull the MySQL image. Once the image is downloaded, let’s create a container from the image like this:

Venkateshs-MacBook-Air:Flask_app venkateshachintalwar$ docker run --name database mysql/mysql-server:5.7
[Entrypoint] MySQL Docker Image 5.7.29-1.1.15
[Entrypoint] No password option specified for new database.
[Entrypoint]   A random onetime password will be generated.
[Entrypoint] Initializing database
[Entrypoint] Database initialized
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone.
...