Build a Dockerfile#
In this lab you will begin working on the
Dockerfile that will be the heart of your project. The Dockerfile takes the place of the manual creation of a container we did in the previous lab. You should carefully track the packages and other software you installed and make sure they become instructions in the Dockerfile.
The Source Code#
In the next lab you’ll create a simple Django app. You should do that lab in the same directory as this lab where you will create a
Dockerfile. After doing the next lab an
./app directory with source code will appear. To implement the next milestone you’ll package the source code using the
Dockerfile from this lab.
The initial contents of your
Dockerfile should be:
FROM docker.io/ubuntu:20.04 # Build your container.
Debugging a Container That Won’t Start#
When you start messing with commands in a container sometimes you get a container that won’t start. The
docker exec command won’t work. But, you can override the command that the container runs on startup using
docker run. Here’s an example:
$ docker run django /bin/sh
The above command prevents your
entrypoint.sh from running and you can look around for problems.