Introduction to Docker

1/8/2025

Introduction to Docker

Docker is a platform for developing, shipping, and running applications in containers.

What is Docker?

Docker allows you to package an application with all of its dependencies into a standardized unit called a container.

Key Concepts

  • Container: A lightweight, standalone package
  • Image: A template for creating containers
  • Dockerfile: Instructions to build an image
  • Registry: A repository for Docker images

Installation

Install Docker Desktop from docker.com

Verify installation:

bash
docker --version
docker run hello-world

Basic Commands

bash
# List running containers
docker ps

# List all containers
docker ps -a

# List images
docker images

# Run a container
docker run nginx

# Run in detached mode
docker run -d nginx

# Stop a container
docker stop <container_id>

Port Mapping

bash
docker run -d -p 8080:80 nginx
# Access at http://localhost:8080