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
- Open a terminal or command prompt.
-
Run the following command to verify that Docker is installed and working:
$ docker --version
-
Ensure you see the Docker version information displayed.
Task 3: Run Your First Docker Container
-
Use the following command to pull and run a simple Docker container that prints a "Hello, Docker!" message:
$ docker run hello-world
-
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
-
Use the following command to list all Docker images available on your system:
$ docker images
-
Observe the list of available images and their details.
Task 5: Run a Custom Container
-
Find a Docker image of your choice on Docker Hub (e.g., "nginx" for a web server).
-
Use the
$ docker run
command to pull and run the chosen image. -
Access the container from a web browser or check its status.
Task 6: Stop and Remove Containers
-
Stop the containers you started in the previous tasks using the
docker stop
command. -
Remove the containers using the
docker rm
command. - 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.