Docker – Container Platform for Building and Running Applications

What is Docker?

Docker is the industry-leading container platform that enables developers to build, share, and run applications in isolated environments called containers. Launched in 2013 by Solomon Hykes, Docker revolutionized software development by making containerization accessible and practical for everyday use.

Containers package an application with all its dependencies, ensuring consistent behavior across development, testing, and production environments. This “build once, run anywhere” approach has transformed how organizations develop and deploy software.

Key Features

  • Containerization: Package applications with all dependencies in portable containers
  • Image management: Build, store, and distribute container images
  • Docker Hub: Access millions of pre-built container images
  • Docker Compose: Define and run multi-container applications
  • Networking: Built-in container networking and service discovery
  • Volume management: Persistent data storage for containers
  • Security: Isolation, secrets management, and content trust
  • Cross-platform: Runs on Linux, Windows, and macOS

Docker vs Virtual Machines

Unlike virtual machines that virtualize hardware, containers virtualize the operating system:

Feature Docker Containers Virtual Machines
Startup Time Seconds Minutes
Size Megabytes Gigabytes
Performance Near native Hardware virtualization overhead
Isolation Process-level Full OS isolation
Portability Excellent Good

System Requirements

  • Linux: 64-bit kernel 3.10+ with cgroups and namespaces
  • Windows: Windows 10/11 Pro/Enterprise with WSL 2
  • macOS: macOS 12+ with Apple Silicon or Intel
  • Minimum 4GB RAM recommended

Installation Guide

debian">Ubuntu/Debian

# Remove old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

# Install dependencies
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

# Add Docker GPG key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list

# Install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# Add user to docker group
sudo usermod -aG docker $USER

rhel-fedora">CentOS/RHEL/Fedora

sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable docker
sudo systemctl start docker

Essential Docker Commands

Container Management

# Run a container
docker run -d --name myapp -p 8080:80 nginx

# List running containers
docker ps

# List all containers
docker ps -a

# Stop a container
docker stop myapp

# Remove a container
docker rm myapp

# View container logs
docker logs myapp

# Execute command in container
docker exec -it myapp bash

Image Management

# Pull an image
docker pull ubuntu:22.04

# List images
docker images

# Build an image
docker build -t myapp:latest .

# Push to registry
docker push myregistry/myapp:latest

# Remove image
docker rmi nginx:latest

Dockerfile Example

# Use official Python runtime as base
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy requirements first for caching
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Expose port
EXPOSE 8000

# Run the application
CMD ["python", "app.py"]

Docker Compose Example

# docker-compose.yml
version: "3.9"
services:
  web:
    build: .
    ports:
      - "8000:8000"
    depends_on:
      - db
    environment:
      - DATABASE_URL=postgres://db:5432/myapp
  
  db:
    image: postgres:15
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=myapp
      - POSTGRES_PASSWORD=secret

volumes:
  postgres_data:

Best Practices

  • Use official base images from trusted sources
  • Keep images small with multi-stage builds
  • Never store secrets in images
  • Use .dockerignore to exclude unnecessary files
  • Run containers as non-root users
  • Scan images for vulnerabilities regularly

Download

Docker is available as Docker Desktop for personal use and Docker Engine for servers:

Download Docker

Latest Version: 24.0
License: Apache 2.0 (Engine)
Developer: Docker, Inc.

Was this article helpful?

R

About Ramesh Sundararamaiah

Red Hat Certified Architect

Expert in Linux system administration, DevOps automation, and cloud infrastructure. Specializing in Red Hat Enterprise Linux, CentOS, Ubuntu, Docker, Ansible, and enterprise IT solutions.

🐧 Stay Updated with Linux Tips

Get the latest tutorials, news, and guides delivered to your inbox weekly.

Add Comment