Docker Day 2: Docker Installation, Architecture and Your First Container
🐳 Docker From Scratch – Day 2
Docker Installation, Architecture & Your First Container
📋 Table of Contents
- Why Install Docker?
- Docker Architecture
- Installing Docker on Ubuntu
- Running Your First Container
- Image vs Container
- Essential Commands
- 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.
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.
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
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
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
| Image | Container |
|---|---|
| Blueprint | Running Instance |
| Static | Dynamic |
| Reusable | Temporary |
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
Post a Comment