Committing a New Container Image

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In this hands-on lab scenario, you will be connecting to and modifying a Docker container. In addition, you will save the container changes to a new image and start a new container from the newly created image. Upon completion of this lab, you will know how to make small modifications to an existing container and save those changes as an image for future use.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Modify a Container
  • Verify the container web-1 is running.
  • Connect to the container.
  • Add the message "A guru was here in this container" to the file /usr/share/nginx/html/index.html.
Commit the Modified Container

Commit the changes to the container web-1 to a new image named server-1:5000/my-web:v1.

Verify the Container Changes
  • Start a new container named web-2 using the image server-1:5000/my-web:v1. Map container port 80 to host port 8080.
  • Using curl and a web browser, verify your changes are present on web-2.

Additional Resources

In this scenario, you have been approached by a colleague from the web development team. They are having some issues creating a new image from a modified container they have running on their development system named server-1. They would like you to try and create a new image. Log in to server-1 and connect to the running container named web-1. Once connected to web-1, modify the file /usr/share/nginx/html/index.html with the simple message of "A guru was here in this container".

After making the changes, you will need to commit those changes to a new image named server-1:5000/my-web:v1. Using this new image, start a container named web-2 with container port 80 mapped to host port 8080. Then use curl and a web browser to verify the new container is working and shows the new message when you access server-1:8080. Good luck Gurus, and have fun.

What are Hands-on Labs

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.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?