- Lab
- A Cloud Guru
Building Container Images Using Dockerfiles
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.
Path Info
Table of Contents
-
Challenge
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
-
Challenge
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.
-
Challenge
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
-
Challenge
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.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.