Introduction
Docker is a platform for building and running containers. Containers package an application together with the files and libraries it needs, so the application behaves more consistently across different environments.
A container is not the same thing as a full virtual machine. It isolates processes and filesystem views while sharing the host kernel, which is one reason containers usually start faster and use fewer resources than VMs.
This became popular because developers and operators often faced the same problem: software worked on one machine but failed on another because the environment was different. Containers reduce that mismatch by standardizing how the application is packaged and started.
In this lab, you will perform a health check on your Docker environment. Before using containers seriously, it is important to verify that the Docker Engine is installed, the client can talk to it, and the system can run a test image successfully.
You will perform the following checks:
- Verify the installed Docker version.
- Run a test container to confirm that your system can download images and execute them.
- Inspect the container's status to understand its lifecycle.
Check Docker Version
The first step in verifying your Docker environment is to check if the Docker command-line interface (CLI) is accessible. This confirms that the docker command is available in your system's PATH.
This check only proves the client tool exists. It does not yet prove that the Docker engine in the background is healthy or that containers can actually run.
Open your terminal and execute the following command:
docker --version
Example Output:
Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.3
The output displays the installed Docker version and build information. Seeing a version number confirms that the Docker client is successfully installed and ready to accept commands.
Run a Test Container
Now that you have confirmed the Docker client is available, the next step is to verify that the Docker Daemon (the background service that manages containers) is running and capable of launching containers.
This client-daemon split is central to Docker. The docker command you type is the client, while the daemon does the real work of pulling images, creating containers, and managing their lifecycle.
We will use the official hello-world image for this purpose. This minimal image is designed specifically to test the installation.
Run the following command in your terminal:
sudo docker run hello-world
Why sudo?
The Docker daemon communicates via a Unix socket. By default, this socket is owned by the root user, and other users can only access it using sudo.
What happens when you run this command?
- Check Local: Docker checks if the
hello-worldimage exists on your local machine. - Pull: If not found locally, Docker downloads (pulls) the image from the Docker Hub (a public registry).
- Run: Docker creates a new container from that image and executes it.
That sequence also introduces the image/container distinction. An image is a reusable template, while a container is a running or stopped instance created from that template.
Analyze Container Output and Status
In this step, you will analyze the output from the previous command to confirm the container ran successfully.
After running sudo docker run hello-world, you should see a message similar to this:
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
This message confirms that the entire Docker pipeline—Client, Daemon, Registry, and Container—is functioning correctly.
The hello-world container is designed to print this message and then immediately exit. Even though it has stopped running, the container still exists on your system. You can verify this by listing all containers, including those that are stopped.
This is a useful first lesson in container lifecycle: a container can exist in an exited state. Running and existing are related but not identical ideas in Docker.
Run the following command:
sudo docker ps -a
ps: Lists containers.-a(or--all): Shows all containers, not just the running ones.
You should see hello-world listed in the output with a status of Exited. This confirms that the container was created, ran, and finished its task successfully.
Summary
In this lab, you successfully verified your Docker installation. You have learned how to:
- Check the Docker version to confirm the CLI tool is installed.
- Run the
hello-worldcontainer to test the connection to the Docker daemon and the ability to pull images. - Verify container execution by inspecting the output and listing container history.
With these checks complete, you can be confident that your environment is ready for more advanced Docker operations.



