Deploy a Flask Application with Dokku

Dokku is a self-hosted Platform-as-a-Service (PaaS) that makes deploying applications simple using Git. Although Dokku’s implementation is similar to Heroku, it lacks certain key features such as auto-scaling. Dokku is an extremely powerful tool that automatically runs your application inside Docker and requires minimal configuration of web servers.

This guide demonstrates how to:

  • Create a Flask application that returns ‘Hello World!’ on the index page
  • Install Dokku on a Linode
  • Deploy a Flask application with a WSGI server inside a Docker container
  • Add an SSL certificate through Dokku with the Let’s Encrypt plugin

Multiple WordPress Sites on Docker

See How Containers Help Deploy Web Applications

Moving from a hosting account to a virtual or dedicated server? With add-on domains in cPanel, you could host a virtually unlimited number of sites on your account. A cloud compute instance, such as one from AWS, provides you with a single IP address. As you might know, only one web server can bind to port 80 at a time – so how do you host multiple websites on your own Linux box?

The amount of CPU and RAM on your own server is more than the shared pool of resources normally on a hosting account. If your websites are not extremely high traffic (less than 5,000 visitors/month), why let the excess resources go to waste? An instance with 2 to 4 GB of RAM could easily host multiple WordPress sites.

You can run multiple WordPress websites using a single MySQL database server and virtual hosts configuration in Apache, but nowadays, there’s an easier, more “cloud native” way to achieve the same result: Docker. Docker is a container runtime that gives each application its own user space, complete with process tree and file system, on a single Linux machine.

Reasons to Use Docker to Containerize Traditional Apps

  • Easy to deploy – With Docker, you pull app images directly from a repository with all the dependencies they need built in. In general, each container is responsible for a single service, hence the saying “micro-services architecture.” In the past, a single “monolithic” app would have many components that you would individually need to download the runtimes for.
  • Portable – If any of your containers outgrow the physical infrastructure it lives on, you can use the commands docker commit (create a new image of the container with your additions to the layered file system), docker export (download a tar archive of the container) and docker save (download a tar archive of the attached volumes) to back it up. With a scheduling and orchestration tool such as Docker Swarm or Kubernetes, you can even scale up a service across a Docker cluster with a single command.
  • Secure – Docker containers are isolated from one another, making it difficult for an attacker to gain access to other services from a single compromised application. Unless you are running a container with the –privilegedflag, a container has very limited permissions on the host system, protecting the kernel from a malicious attack.