Creating a container image by hand is possible, but it requires manual processes. There has to be a more automatic way to build images. Manual processes do not scale and are not easily version controlled. Docker provides a solution to this problem – the Dockerfile. In this lab, you will create a Dockerfile to build an image to host a static website.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Build a First Version
- Create a Dockerfile that uses
httpd:2.4
as the base image, then runs basic package updates. - Build the
0.1
version of thewidgetfactory
image using the Dockerfile. - Inspect the image to see its size and layers.
- Create a Dockerfile that uses
- Load the Website into the Container
- Remove the Apache welcome page from the image.
- Build version
0.2
of the widgetfactory image. - Inspect both versions of the
widgetfactory
image to see the differences in size and layers. - Add the website data to the container.
- Build version
0.3
of the widgetfactory image. - Inspect versions
0.2
and0.3
to see the differences in size and layers.
- Run a Container from the Image
- Run a container from the
widgetfactory:0.3
image in the terminal, to see which command it executes. Remember to publish the web server port. - Stop the container running in the terminal, then start it in detached mode.
- View the website files in the container.
- Retrieve the main website page from the container and compare it to the copy on the server.
- Run a container from the
- Read Me
Note: Many of the things done in this lab are intentionally inefficient, These tasks are done to demonstrate certain aspects of Docker, and highlight common pitfalls. These do not represent best practices.