Skip to content

Practice Exercise 1:Introduction in Installing and Running Docker Containers

Objective

To become familiar with Docker container installation and basic container operations.

Prerequisites

  • A computer with a suitable operating system (Linux, Windows, or macOS) for Docker installation.
  • A stable internet connection.
  • Administrative access to the computer (for installation).

Duration: 60 minutes

Tasks

Task 1: Install Docker

    Install Docker on your computer (local). You can follow the official installation guide for your specific operating system.

Task 2: Verify Docker Installation

  1. Open a terminal or command prompt.
  2. Run the following command to verify that Docker is installed and working:

    $ docker --version
    
  3. Ensure you see the Docker version information displayed.

Task 3: Run Your First Docker Container

  1. Use the following command to pull and run a simple Docker container that prints a "Hello, Docker!" message:

    $ docker run hello-world
    
  2. Observe the output and ensure that the container runs successfully.

    Note: If hello-world image is not available upon installation of docker you can pull the image from docker public registry

Task 4: Explore Container Images

  1. Use the following command to list all Docker images available on your system:

    $ docker images
    
  2. Observe the list of available images and their details.

Task 5: Run a Custom Container

  1. Find a Docker image of your choice on Docker Hub (e.g., "nginx" for a web server).

  2. Use the $ docker run command to pull and run the chosen image.

  3. Access the container from a web browser or check its status.

Task 6: Stop and Remove Containers

  1. Stop the containers you started in the previous tasks using the docker stop command.

  2. Remove the containers using the docker rm command.

  3. Verify that the containers are no longer running or listed.

Conclusion

In this lab exercise, you have successfully installed Docker, verified the installation, and performed basic operations such as running, listing, stopping, and removing containers. These foundational skills are essential for working with Docker containers.

Note: This is a simple introductory exercise. You can expand on this by exploring more complex use cases, working with Docker Compose for multi-container applications, and exploring various Docker images for different services.