πŸš€ Day-1: Docker Installation & Getting Started

Ibrar AnsariIbrar Ansari
4 min read

Welcome to Day-1 of learning Docker! In this guide, we'll cover how to install Docker, verify the installation, run your first container, and have a little fun with a live web server example. πŸŽ‰

🎬 Video Demonstration

Watch on Youtube

πŸ”§ Step 1: Install Docker

πŸ‘‰ Official Docs:

πŸ’‘ After installation, make sure Docker Desktop is running (Windows/macOS), or the Docker daemon is active (Linux).


βœ… Step 2: Verify Installation

Run the following commands in your terminal to ensure Docker is properly installed:

docker --version                   # βœ… Docker version
docker-compose --version          # βœ… Docker Compose version
docker info                       # ℹ️  General system info
docker info --format '{{.ServerVersion}}'   # 🎯 Server version only
docker info --format '{{.ClientInfo}}'      # 🎯 Client info only
docker info | grep "Docker Root Dir:" # πŸ“ Find the Docker root directory path
sudo ls -alsh  /var/lib/docker # πŸ“‚ List contents of the Docker root directory
total 52K
4.0K drwx--x--- 12 root root 4.0K May 24 23:13 .                # This directory itself
4.0K drwxr-xr-x 74 root root 4.0K May 15 21:42 ..               # Parent directory
4.0K drwx--x--x  4 root root 4.0K Aug 25  2024 buildkit         # πŸ’‘ Used for efficient image builds with BuildKit
4.0K drwx--x---  2 root root 4.0K May 24 23:13 containers       # πŸ“¦ Stores container metadata and logs
4.0K -rw-------  1 root root   36 Aug 25  2024 engine-id        # πŸ†” Unique ID for this Docker engine instance
4.0K drwx------  3 root root 4.0K Aug 25  2024 image            # πŸ–ΌοΈ Stores image metadata and layers
4.0K drwxr-x---  3 root root 4.0K Aug 25  2024 network          # 🌐 Docker network configuration and data
4.0K drwx--x--- 32 root root 4.0K May 24 23:13 overlay2         # πŸ“‚ Default storage driver directory (overlay2)
4.0K drwx------  4 root root 4.0K Aug 25  2024 plugins          # πŸ”Œ Installed Docker plugins (e.g. volume or network)
4.0K drwx------  2 root root 4.0K May 24 23:13 runtimes         # ⏱️ Runtime binaries (like runc or containerd)
4.0K drwx------  2 root root 4.0K Aug 25  2024 swarm            # 🐝 Docker Swarm cluster data (if used)
4.0K drwx------  2 root root 4.0K May 24 23:13 tmp              # πŸ§ͺ Temporary files used by Docker daemon
4.0K drwx-----x  3 root root 4.0K May 24 23:13 volumes          # πŸ“¦ Volume data used by containers
🧠 Summary
| ------------- | --------------------------------------------------------- |
| Folder        | Description                                               |
| ------------- | --------------------------------------------------------- |
| `buildkit/`   | Docker's modern build engine files                        |
| `containers/` | Metadata and runtime logs for each container              |
| `engine-id`   | Unique ID for your Docker engine installation             |
| `image/`      | Metadata and layers for container images                  |
| `network/`    | Network config (bridge, host, etc.)                       |
| `overlay2/`   | Union file system used by Docker to store container files |
| `plugins/`    | Installed plugins                                         |
| `runtimes/`   | Container runtime definitions (e.g., `runc`)              |
| `swarm/`      | Swarm mode cluster information                            |
| `tmp/`        | Temporary working data                                    |
| `volumes/`    | Persistent volumes mounted into containers                |
| ------------- | --------------------------------------------------------- |

🐧 For Linux users only:

sudo systemctl status docker      # πŸ” Check Docker daemon status
sudo journalctl -u docker         # πŸ“œ Docker logs

πŸ§ͺ Step 3: Test Docker

Run a test container to verify everything works:

docker run hello-world            # πŸš€ Runs a simple test container
docker ps                         # πŸ“‹ List running containers
docker ps -a                      # πŸ“‹ List all containers (including stopped)
docker images                     # πŸ—‚οΈ  List downloaded images

πŸŽ‰ Step 4: Fun Example – Run NGINX Web Server

docker pull nginx                 # ⬇️ Pull the latest NGINX image
docker run -d -p 8080:80 nginx    # 🌐 Start web server on localhost:8080

πŸ–₯️ Open your browser and go to: http://localhost:8080 or use IP, in my case http://192.168.1.22:8080

You’ll see the default NGINX welcome page served from inside a Docker container!


🧹 Step 5: Clean Up Docker Resources

docker system df                  # πŸ“Š View disk usage
docker system prune               # 🧼 Clean up unused containers, networks, images

⚠️ docker system prune will prompt you before deletion. Make sure you don’t need any data it will remove!


πŸ“ Summary

CommandDescription
docker --versionShow Docker version
docker run hello-worldTest Docker setup
docker pull nginxDownload the NGINX image
docker run -d -p 8080:80 nginxStart NGINX container
docker system pruneRemove unused data

πŸ“Œ Next up: Learn how to run your Docker containers like a pro. πŸ’ͺ


πŸ‘‹ Happy Dockering!

0
Subscribe to my newsletter

Read articles from Ibrar Ansari directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ibrar Ansari
Ibrar Ansari

Hello! I'm a DevOps Engineer dedicated to continuous learning and contributing to the tech community. If you find value in what I share, feel free to spread the word to others who might benefit as well. Your support is greatly appreciated!