Installing & Setting Up Docker – Your First Steps


1. Introduction

Docker makes it easy to package and run applications in a consistent environment, but before you start using it, you need to install and set it up properly. This guide will walk you through installing Docker on Windows, macOS, and Linux, running your first container, and understanding the basics of Docker CLI.


2. How to Install Docker on Windows, macOS, and Linux

Before installing Docker, ensure your system meets the minimum requirements.

🔹 Windows & macOS (Using Docker Desktop)

  1. Download Docker Desktop:

  2. Install Docker Desktop: Follow the installation wizard and restart your system if required.

  3. Run Docker: Open Docker Desktop and ensure it starts without errors.

🔹 Linux (Using Terminal)

  1. Update system packages:

     sudo apt update && sudo apt upgrade -y  # For Debian/Ubuntu
     sudo dnf update -y  # For Fedora
    
  2. Install Docker:

     sudo apt install docker.io -y  # Debian/Ubuntu
     sudo dnf install docker -y  # Fedora
    
  3. Start Docker service:

     sudo systemctl start docker
     sudo systemctl enable docker  # Auto-start on boot
    
  4. Verify installation:

     docker --version
    

3. Understanding Docker CLI & Docker Desktop

Once Docker is installed, you can use Docker CLI (Command Line Interface) or Docker Desktop UI to manage containers.

🔹 Docker CLI Basics

  • Check if Docker is running:

      docker info
    
  • List running containers:

      docker ps
    
  • List all containers (including stopped ones):

      docker ps -a
    

🔹 Docker Desktop Overview

  • Provides a graphical interface to manage containers.

  • Includes tools like Docker Extensions for better functionality.

  • Recommended for Windows and macOS users.


4. Running Your First Docker Container

Now that Docker is installed, let's run a simple container to test it.

Hello-World Container (First Test)

Run the following command in your terminal or command prompt:

docker run hello-world

✅ If Docker is working correctly, you’ll see a message confirming successful installation.

Running an Nginx Web Server

To run an Nginx container on your system:

docker run -d -p 8080:80 nginx

Now, open your browser and go to localhost:8080 – you should see the Nginx welcome page! 🎉


5. Verifying Installation & Troubleshooting Issues

🔹 Common Issues & Fixes

  • Docker not starting on Windows/macOS?

    • Restart your system and try again.

    • Ensure Virtualization is enabled in BIOS.

  • Permission denied on Linux?

    • Run Docker commands with sudo or add your user to the Docker group:

        sudo usermod -aG docker $USER
        newgrp docker
      
  • Error pulling images?

    • Check your internet connection.

    • Run docker login if pulling private images.


6. Exploring Basic Docker Commands

Here are some useful Docker commands to get started:

CommandDescription
docker pull <image>Download a Docker image from Docker Hub.
docker imagesList downloaded images.
docker ps -aList all containers.
docker start <container>Start a stopped container.
docker stop <container>Stop a running container.
docker rm <container>Remove a container.
docker rmi <image>Remove an image.

7. Conclusion

Congratulations! 🎉 You’ve successfully installed Docker, run your first container, and explored some basic commands. Now, you can start building and running applications in Docker effortlessly!

Next Steps? Try running more containers and explore Docker Hub for exciting pre-built images. 🚀