Exercise: Docker Based Apps

Exercise: Docker-based Apps

If you haven’t already, clone the course repository and navigate to the containerization directory. You’ll use the code there to containerize a pre-built application with Docker.

Instructions

  • Navigate to the containerization director in the Github repo.
  • Check out the pre-built Flask app that will be containerized. If you haven’t used Flask before, you can check out this free Udacity course, or check out Flask’s documentation.
  • Look through the Dockerfile for the container (also included below).
  • Look through the Makefile to be run within the container.

The only real new thing so far is the inclusion of the Flask app – you got familiar with Dockerfiles and Makefiles in the Using Docker Format Containers Lesson, as well as how to create them. There are some additional steps we still want to go through to get the App up and running, but the important thing to notice here is that it doesn’t necessarily matter what the application itself is, you can still easily containerize it.

Noah’s Dockerfile

The Dockerfile in Noah’s video is provided below:

FROM python:3.7.3-stretch

# Working Directory
WORKDIR /app

# Copy source code to working directory
COPY . flask_app/web.py /app/

# Install packages from requirements.txt
# hadolint ignore=DL3013
RUN pip install --upgrade pip &&
    pip install --trusted-host pypi.python.org -r requirements.txt

# Expose port 80
EXPOSE 80

# Run app.py at container launch
CMD ["python", "web.py"]

Reference