Now that you’re familiar with what Docker is and why it’s so powerful, it’s time to dive into the practical side of things. In this article, we’ll guide you through installing Docker on various platforms, ensuring you have the tools ready to start your containerization journey.
Prerequisites
Before installing Docker, ensure the following:
- Your system meets the minimum requirements for Docker installation.
- You have administrative access to your machine.
- A stable internet connection to download installation files.
Installing Docker
Below are step-by-step instructions for setting up Docker on popular platforms.
1. Installing Docker on Windows
Steps:
I. Download Docker Desktop:
- Visit the Docker Desktop download page.
- Download the installer for Windows.
II. Install Docker Desktop:
- Run the downloaded installer.
- Follow the on-screen instructions to complete the installation.
- During the setup, ensure that the "Use WSL 2 instead of Hyper-V" option is selected (recommended).
III. Start Docker:
- Open Docker Desktop and follow the initialization process.
-
Verify the installation by running:
docker --version
2. Installing Docker on macOS
Steps:
I. Download Docker Desktop:
- Navigate to the Docker Desktop for Mac page.
- Download the installer for macOS.
II. Install Docker Desktop:
- Open the downloaded
.dmg
file and drag the Docker icon to your Applications folder.
III. Start Docker:
- Launch Docker from the Applications folder.
- Complete the onboarding process.
-
Verify the installation by running:
docker --version
3. Installing Docker on Linux
Supported Distributions:
Docker supports major Linux distributions such as Ubuntu, Debian, Fedora, and CentOS.
Steps for Ubuntu/Debian:
I. Update the Package Index:
sudo apt update
II. Install Prerequisites:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
III. Add Docker’s Official GPG Key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
VI. Add Docker Repository:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
V. Install Docker:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
VI. Verify Installation:
docker --version
Post-Installation Steps
Verify Docker Installation
To ensure Docker is installed correctly, run the following command:
docker run hello-world
This command pulls a test image from Docker Hub and runs it in a container. If successful, you’ll see a message confirming that Docker is working.
Optional: Manage Docker as a Non-Root User
For Linux users, running Docker commands without sudo
can improve convenience. Add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect.
Conclusion
With Docker installed on your machine, you’re ready to start working with containers. In the next article, we’ll explore Docker images and containers, diving into how to build, pull, and run them. Stay tuned!
Top comments (0)