Docker Day 2: Docker Installation, Architecture and Your First Container

Docker Day 2: Installation, Architecture and Your First Container

🐳 Docker From Scratch – Day 2

Docker Installation, Architecture & Your First Container

📋 Table of Contents

  1. Why Install Docker?
  2. Docker Architecture
  3. Installing Docker on Ubuntu
  4. Running Your First Container
  5. Image vs Container
  6. Essential Commands
  7. Hands-on Practice

Why Install Docker?

In Day 1 we learned why containers were created and how they solved the limitations of Virtual Machines. Today we move from theory to practice.

Analogy: Learning Docker without installing it is like learning how to drive by only reading a car manual. Eventually you must sit in the driver's seat.

Docker Engine is the software responsible for building images, creating containers, networking, storage management and execution of containerized applications.

Docker Architecture

Whenever you run a Docker command, several components work together.

Developer
    ↓
Docker CLI
    ↓
Docker Engine
    ↓
Docker Images
    ↓
Docker Containers

Docker CLI

The Docker CLI is the interface we use to communicate with Docker.

docker run nginx
docker ps
docker images

Docker Engine

The engine acts as the brain of Docker. It receives commands from the CLI and performs the requested actions.

Analogy: Think of Docker CLI as a restaurant customer and Docker Engine as the chef. The customer places an order; the chef prepares and serves it.

Docker Registry

A registry stores container images. The most popular public registry is Docker Hub.

Installing Docker on Ubuntu

Step 1: Update Packages

sudo apt update

Step 2: Install Docker

sudo apt install docker.io -y

Step 3: Start Docker Service

sudo systemctl start docker

Step 4: Enable Docker at Boot

sudo systemctl enable docker

Verify Installation

docker --version
sudo systemctl status docker
If you see "active (running)", Docker is installed and running successfully.

Running Your First Container

Let's run the famous hello-world container.

docker run hello-world

Docker automatically:

  • Checks if the image exists locally
  • Downloads it if missing
  • Creates a container
  • Runs the container
Analogy: Ordering food through a delivery app. If the food isn't in your house, it gets fetched from the restaurant, delivered, and served automatically.

Run Nginx

docker run -d -p 8080:80 nginx

This means:

  • -d → Run in background
  • -p → Port mapping
  • 8080 → Host port
  • 80 → Container port

Docker Image vs Container

ImageContainer
BlueprintRunning Instance
StaticDynamic
ReusableTemporary
Analogy: An image is a recipe book. A container is the actual meal prepared from that recipe.

Essential Docker Commands

docker images
docker ps
docker ps -a
docker pull nginx
docker run nginx
docker stop CONTAINER_ID
docker start CONTAINER_ID
docker rm CONTAINER_ID
docker logs CONTAINER_ID
docker exec -it CONTAINER_ID bash

Hands-On Practice

Try the following exercises:

docker pull nginx
docker run -d nginx
docker ps
docker logs CONTAINER_ID
docker exec -it CONTAINER_ID sh

🎯 Day 2 Recap

  • Installed Docker on Ubuntu
  • Understood Docker Architecture
  • Learned Docker CLI and Engine
  • Ran the first container
  • Understood Image vs Container
  • Practiced essential Docker commands

🚀 Day 3 Preview

Next we'll learn Dockerfiles, build custom images, understand FROM, COPY, RUN and CMD instructions, and create our own containerized application.

Comments

Popular posts from this blog

Linux Commands Every DevOps Engineer Must Know (2026 Complete Guide)

Docker Day 1: Containers Explained — VM vs Docker, Lifecycle & Buildah

Kubernetes Day 7: ConfigMaps & Secrets — Managing Config the Right Way