Docker, how I did it.

This is less of a guide and more of a retelling of how I did it. While I was trying to build the docker container I ran into several issues. I don’t really know how to use Docker very well. I understand what it is, and the basics, it’s not a hard concept, but I didn’t understand how to use it.

For those who may not be privy to what Docker is, it is containerization and you can ship a fully ready app with just a docker image. This is, of course, meant for servers. At this point I had gone through several guides on how to build a Flask Docker container. Eventually I found one that almost got me there. There were still a few things I was missing. As such I had to do some work.

FROM python:3.7.3-slim

COPY requirements.txt /
RUN pip3 install -r /requirements.txt

COPY ./app /app


Is what I ultimately settled on as working. This is running off a few assumptions.

  1. your code is compatible with this version of Python (Mine is)
  2. You have a valid requirements.txt in the same directory as your docker file
  3. You have in the app directory of your project
  4. you have your app stored in ./app.

So the code in ./app is not important. is important. It’s contents are below


gunicorn --chdir /app app:app -w 2 --threads 2 -b

As you can see it’s pretty simple but it does start gunicorn

As part of the process my requirements.txt is pretty simple right now as well but will grow as this project grows.


As you can see everything you’d need to just get Flask up and running is here. This got the basic app up and running. Now I want to finish the login and session validation.

Leave a Reply

Your email address will not be published. Required fields are marked *