Introduction: Docker — The Genie in a Bottle
Imagine you’ve just discovered a magical tool that lets you summon and run applications instantly, anywhere, without the “it works on my machine” curse. That’s Docker! Whether you’re a developer building your next big idea or a student exploring containerization, learning to install Docker is your first step into this fascinating world.
In this guide, I’ll walk you through how to set up Docker on two of the most popular platforms: Ubuntu and Windows. Let’s unbox Docker together!
Setting the Stage: Prerequisites
Before we dive into installation, let’s ensure your system is ready for Docker.
Ubuntu Users: A 64-bit OS and sudo privileges are all you need.
Windows Users: Ensure you’re running Windows 10/11 Pro, Enterprise, or Education with virtualization enabled. WSL2 will also be your ally here.
Act 1: Installing Docker on Ubuntu — The Linux Symphony
Step 1: Update the Orchestra
First, ensure all your packages are in tune:
sudo apt update && sudo apt upgrade -y
Step 2: Clear the Stage
Remove any older versions of Docker:
sudo apt remove docker docker-engine docker.io containerd runc
Step 3: Fetch the Docker Notes
Install required tools to fetch Docker’s GPG key and repository:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 4: Add Docker’s Signature
Bring Docker’s key to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add the repository with the following command:
sudo add-apt-repository "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 5: Install Docker Engine
Finally, let’s install Docker:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Step 6: Test the Magic
Run a quick test to ensure Docker is alive:
sudo docker run hello-world
Step 7: Verify the Docker installation
sudo systemctl status docker
You should see Docker active and running.
Step 8: Run Docker as a non-root user
Add your user to the Docker group:
sudo usermod -aG docker ${USER}
To apply the group changes:
su - ${USER}
Verify by running:
docker run hello-world
Act 2: Installing Docker on Windows — The Desktop Tango
Step 1: Meet Docker Desktop
Head over to Docker Desktop for Windows and download the installer.
Step 2: Enable Virtualization
Ensure your machine is ready to dance with WSL2. Open PowerShell as Administrator and run:
wsl --install
Step 3: Install and Launch
Run the Docker Desktop installer, follow the wizard, and enable WSL2 integration during setup. Once installed, launch Docker Desktop and complete the onboarding.
Step 4: Spin Your First Container
Test Docker with the iconic command:
docker run hello-world
Pro Tips for Docker Success
- Ubuntu Users: Add yourself to the
docker
group to avoid typingsu
do
:
sudo usermod -aG docker $USER
Windows Users: Customize Docker Desktop settings to allocate more resources for heavy workloads.
Both Platforms: Start your Docker journey with the
docker-compose
tool to manage multi-container apps.
Troubleshooting: When the Genie Needs a Push
Ubuntu Issues: Facing permission errors? Ensure you’ve added your user to the Docker group.
Windows Woes: Virtualization errors? Double-check if it’s enabled in the BIOS.
Conclusion: Docker Installed, What’s Next?
Congratulations! You’ve unboxed Docker and set it up on your machine. With this newfound power, you’re ready to dive into containerized application development. Your first task? Spin up a simple web app, or try experimenting with Docker Compose.
Remember, with Docker, the possibilities are limitless. Let’s containerize the future, one application at a time!
Thank you for taking the time to read my blog. Your feedback is immensely valuable to me. Please feel free to share your thoughts and suggestions.