
Ensure that your system meets all prerequisites before proceeding with the Docker installation.
Step 1: Remove Older Docker Versions
Before installing Docker, it is crucial to remove any existing Docker packages. Run the following command:Step 2: Install Docker
There are two primary methods to install Docker: using the package manager or the convenience installation script.Option 1: Using the Package Manager
-
Update the Repository and Install Prerequisites
Update your package list and install necessary packages: -
Add Docker’s Official GPG Key
Add the GPG key for Docker: -
Verify the GPG Key Fingerprint
Run the following command and ensure the output matches:
The expected output should look like:
Option 2: Using the Convenience Installation Script
If you prefer a simpler method, use Docker’s convenience script:Step 3: Verify Docker Installation
After installation, check Docker’s version to confirm the installation:Step 4: Run a Docker Container
To confirm Docker is running correctly, try launching a simple container. Docker Hub offers a variety of images; in this guide, we’ll use the fun “whalesay” image.-
Run the Initial Container Command
Expected output:
-
Modify the Command with Sudo and Change the Message
When executed, Docker pulls the whale image from Docker Hub and displays a message:


While this guide provides an overview of setting up Docker, hands-on labs are available for those who want to experiment and gain further practical experience.