Running Flask in containers
Containers have become very popular in the last few years. They offer more abstractions and virtualization beyond hypervisor-based virtual machines. An in-depth discussion of containers is beyond the scope of this book. For interested readers, we will offer a simple example of how we can run our Flask app in a Docker container.
We will build our example based on the free DigitalOcean Docker tutorial on building containers on Ubuntu 18.04 machines (https://www.digitalocean.com/community/tutorials/how-to-build-and-deploy-a-flask-application-using-docker-on-ubuntu-18-04). If you are new to containers, I would highly recommend that you go through that tutorial and return to this section after.
Let's make sure Docker is installed:
$ sudo docker --version
Docker version 19.03.2, build 6a30dfc
We will make a directory named TestApp
to house our code:
$ mkdir TestApp
$ cd TestApp/
In the directory, we will make another...