Exercise 1: Creating and Using Containers
This exercise guides you through the basics of using existing Docker container images to run containers, as well as creating and using your own container images and containers. These steps assume you have Docker Desktop installed, as per the Technical requirements section at the start of this chapter.
Task 1: Using an Existing Container Image
Follow these steps to cache an existing container image to your local machine and run a container from it:
- Open a new terminal session.
- Pull down the latest official
ubuntu
container image with the following command:docker pull ubuntu:latest
- To list all your local Docker images, run the following command:
docker images
- Note that you now have the
ubuntu:latest
Docker image listed.IMAGE ID
shows the first few characters of the Secure Hash Algorithm 256-bit (SHA256) hash ID of the image. - Run the container interactively (using the
-it
switch) with the following:docker run -it...