Difficulty: intermediate
Estimated Time: 30 minutes

BoxBoat Logo

Dockerfile Lab #2

Let's get more experience creating Dockerfiles.

Please email feedback to: [email protected]

Now that we've gotten more experience working with Dockerfiles, let's learn how to simplify the creation and configuration of Docker containers.

Dockerfiles

Step 1 of 3

Base Python Image

Create a Base Image

One of the first things you'll do from a development perspective is create a base image for all of your applications to use. In reality, your platform team typically creates these, and provides them to internal software development teams for usage.

We will create a basic base image for Python applications. Work together in teams of 2-3 people, and create a Dockerfile (/root/resources/python/Dockerfile) with the following specifications:

  1. Base it off a recent Alpine Linux version
  2. Specify a maintainer
  3. Install Python, Pip, and the dev tools
  4. Install virtualenv
  5. Configure the container to always run python3

Once you have your Dockerfile, build the image:

docker image build -t py /root/resources/python/

Then, to verify that it works properly:

docker container run -d -p 8080:5000 py -m http.server 5000

You should be able to access your filesystem on port 8080.