Docker Fundamentals
Introduction to Container Technology
Docker is a powerful platform for container technology, enabling developers to package, distribute, and run applications efficiently. Containers provide lightweight, portable environments that encapsulate software and its dependencies.
Core Docker Concepts
graph TD
A[Docker Engine] --> B[Container]
A --> C[Image]
A --> D[Dockerfile]
Concept |
Description |
Docker Image |
Read-only template containing application code and dependencies |
Container |
Runnable instance of a Docker image |
Docker Engine |
Runtime environment for creating and managing containers |
Installing Docker on Ubuntu 22.04
## Update system packages
sudo apt update
## Install required dependencies
sudo apt install apt-transport-https ca-certificates curl software-properties-common
## Add Docker's official GPG key
curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
## Set up Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
## Install Docker
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Basic Docker Commands
## Check Docker version
docker --version
## Pull an Ubuntu image
docker pull ubuntu:latest
## List available images
docker images
## Run a container
docker run -it ubuntu:latest /bin/bash
## List running containers
docker ps
Understanding Container Lifecycle
Containers provide isolated environments with their own filesystem, processes, and network interfaces. They can be started, stopped, moved, and deleted quickly, making them ideal for microservices and cloud-native applications.