How to Install Docker: A Step-by-Step Guide
Docker is an open-source platform that automates the deployment, scaling, and management of applications inside lightweight containers. This guide will help you install Docker on Windows, macOS, and Linux.
1. Installing Docker on Windows
Step 1: Download Docker Desktop for Windows
Visit this https://docs.docker.com/engine/install/
Click on the Download for Windows button to download the installer.
Step 2: Install Docker Desktop
Run the downloaded installer.
Follow the installation instructions. Ensure you select the option to install required dependencies like WSL 2 (Windows Subsystem for Linux 2).
Step 3: Start Docker Desktop
After installation, start Docker Desktop from the Start menu.
Wait for Docker to start and complete the setup process.
Step 4: Verify Installation
Open a Command Prompt or PowerShell window and run:
You should see the Docker version information.
docker --version
2. Installing Docker on macOS
Step 1: Download Docker Desktop for Mac
Visit the Docker Desktop for Mac download page.
Click on the Download for Mac button to download the installer.
Step 2: Install Docker Desktop
Open the downloaded
.dmg
file.Drag the Docker icon to the Applications folder.
Step 3: Start Docker Desktop
Open Docker from the Applications folder.
Wait for Docker to start and complete the setup process.
Step 4: Verify Installation
Open a terminal window and run:
docker --version
You should see the Docker version information.
3. Installing Docker on Linux
Step 1: Update Your Package Manager
Open a terminal window and run:
sudo apt-get update
Step 2: Install Required Packages
Run the following command to install the necessary packages:
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker’s Official GPG Key
Run:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 4: Add the Docker APT Repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 5: Update the Package Database
sudo apt-get update
Step 6: Install Docker
sudo apt-get install docker-ce
Step 7: Start and Enable Docker
sudo systemctl start docker
sudo systemctl enable docker
Step 8: Verify Installation
Run:
docker --version
You should see the Docker version information.
Post-Installation Steps (Optional)
Manage Docker as a Non-Root User
To run Docker commands without sudo
, follow these steps:
Create a Docker group:
sudo groupadd docker
Add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and log back in to apply the changes.
Test Docker Installation
Run the following command to test Docker:
docker run hello-world
You should see a message indicating that Docker is working correctly.
Subscribe to my newsletter
Read articles from Shubham Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by