🐳 How to Install and Set Up Docker on Linux (Ubuntu) — Step-by-Step Guide with Commands Explained


If you're new to Docker and running a Linux distribution like Ubuntu, setting up Docker can seem intimidating. But don't worry—this guide walks you through every command used during installation, with simple explanations so you know exactly what’s happening behind the scenes.
🔧 Step 1: Update Your Package List
sudo apt update
📌 What it does: Refreshes your system's list of available packages.
🚀 Why it matters: Ensures you install the latest Docker version from Ubuntu’s repositories.
💡 Think of it like: Checking for software updates before downloading an app.
🐳 Step 2: Install Docker Engine
sudo apt install
docker.io
📌 What it does: Installs Docker on your system using Ubuntu's official
docker.io
package.ℹ️ Note:
docker.io
is the community version provided by Ubuntu.docker-ce
is the official Docker version, typically installed via Docker’s own repository.
💡 Tip: If you're just getting started, docker.io
works perfectly for most use cases.
▶️ Step 3: Start the Docker Service
sudo service docker start
📌 What it does: Launches the Docker daemon (background process).
⚙️ Why it matters: Docker commands won’t work until the service is running.
🔁 Step 4: Enable Docker to Start on Boot
sudo systemctl enable docker
📌 What it does: Automatically starts Docker every time your machine reboots.
👍 Why it's useful: You don’t have to remember to start Docker manually after every system restart.
✅ Step 5: Verify Docker is Running
sudo systemctl status docker
📌 What it does: Displays the current state of the Docker service.
🟢 Useful for: Making sure Docker is active and running properly.
📝 Full Setup Summary
sudo apt update # Step 1: Update package list
sudo apt install docker.io # Step 2: Install Docker
sudo service docker start # Step 3: Start Docker service
sudo systemctl enable docker # Step 4: Auto-start on boot
sudo systemctl status docker # Step 5: Check Docker status
🏬 Using Docker Hub
Once Docker is installed, you’ll probably want to run your first container. That starts with pulling an image from Docker Hub—Docker’s official cloud-based image registry.
🤔 What is Docker Hub?
Think of it as the App Store for Docker images. You can find everything from Linux distros (like Ubuntu and Alpine) to full-blown web servers (like NGINX or Apache).
📥 Command: docker pull
docker pull <image_name>
- 📌 What it does: Downloads an image from Docker Hub to your local system.
🔍 Example:
docker pull ubuntu
This downloads the official Ubuntu image.
📦 With a Tag:
docker pull nginx:alpine
This pulls the lightweight Alpine-based NGINX image.
💡 Why Use docker pull
?
🔄 You get prebuilt, ready-to-use containers in seconds.
🚀 Saves time—you don’t need to create everything from scratch.
🧰 Useful for running apps, services, or development environments locally.
✅ You’re Ready to Docker!
That’s it! You’ve installed Docker, enabled it to run on boot, verified it’s working, and learned how to fetch container images from Docker Hub. 🚀
🗨️ Got questions or stuck somewhere?
Drop a comment below—I'd love to help!
Or follow me for more tips on Docker, DevOps, and cloud-native development. 👨💻
Subscribe to my newsletter
Read articles from Sonica Sonawane directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sonica Sonawane
Sonica Sonawane
Hi, I'm Sonica! 👋 I’m currently diving into the world of DevOps, focusing on AWS, Docker, Kubernetes, Linux, and GitHub. My passion lies in automating systems, building cloud infrastructure, and optimizing workflows. I’m committed to continuous learning, hands-on projects, and sharing my journey with others in the tech community. Before shifting to DevOps, I worked in IT Sales, where I gained valuable skills in client communication, requirement gathering, and problem-solving. This experience taught me how to connect technical solutions to business needs, which has been instrumental as I transition into DevOps, where technical expertise and problem-solving go hand in hand. Now, I’m eager to apply my sales experience alongside my growing technical skills in cloud engineering and DevOps. Join me as I explore the latest trends, challenges, and solutions in the world of cloud computing!