2.2 Lab - Introduction to Docker

Introduction

Welcome to the "Introduction to Docker" hands-on lab, where you will get your first taste of working with Docker through the command line interface (CLI). This lab is designed to provide you with practical experience in using Docker, focusing on basic commands and operations. By the end of this lab, you will have learned how to manage Docker images and containers directly from your terminal using a Linux environment and the Nano editor.

Objectives

Lab Steps

Step 1: Setting Up Your Environment

Step 2: Pulling a Docker Image

Step 3: Running a Docker Container

Step 4: Managing Docker Containers

Step 5: Accessing and Managing Container Logs

Step 6: Executing Commands Inside a Running Container

Step 7: Cleanup

docker ps

You should see something like the following:

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
55c609cf59ad   nginx     "/docker-entrypoint.…"   3 minutes ago   Up 3 minutes   80/tcp    my-nginx

Now stop the running container use the id listed in the previous command. Note your id will bw different.

rm -f 55c609cf59ad

Run the 'docker ps' command again to verify

docker ps

There should be no containers running now.

CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

Summary

In this introductory lab to Docker, you've taken your first steps into the world of Docker containers. You've learned how to pull images from Docker Hub, run containers, and manage them using basic Docker CLI commands. Additionally, you've explored accessing container logs and executing commands inside running containers. These foundational skills are crucial as you continue to explore more complex Docker functionalities in future labs. Docker opens up a world of possibilities for developing, shipping, and running applications, and you're now equipped with the knowledge to begin experimenting on your own.