TU24x7Technical Knowledge Base

Docker Foundations

Overview

Docker is a containerization platform that enables applications to run in isolated environments while sharing the host operating system kernel.

Containers provide a lightweight alternative to traditional virtual machines, offering faster deployment, lower resource consumption, and improved portability.


Learning Objectives

After completing this section, you should be able to:

  • Understand Docker architecture and core concepts.
  • Install and manage Docker on Linux systems.
  • Create, run, and manage containers.
  • Persist application data using volumes.
  • Configure container networking.
  • Deploy multi-container applications using Docker Compose.
  • Implement backup and recovery strategies.
  • Apply container security best practices.
  • Deploy real-world services using containers.

Why Docker?

Traditional virtual machines require a complete operating system for each workload.

Docker containers share the host kernel while maintaining process isolation.

Benefits

  • Faster deployment
  • Lower memory usage
  • Improved scalability
  • Simplified application packaging
  • Consistent environments across development, testing, and production
  • Easier disaster recovery and migration

Containers vs Virtual Machines

| Feature | Virtual Machine | Container | | ---------------------- | --------------- | ------------- | | Guest Operating System | Required | Not Required | | Startup Time | Minutes | Seconds | | Resource Consumption | High | Low | | Isolation | Strong | Process Level | | Portability | Moderate | High | | Density per Host | Low | High |


Docker Architecture

Docker consists of several core components.

Docker Engine

The runtime responsible for building, running, and managing containers.

Images

Read-only templates used to create containers.

Examples:

  • nginx
  • ubuntu
  • debian
  • mariadb
  • postgres
  • nextcloud

Containers

Running instances of Docker images.

Containers are isolated processes that share the host kernel.

Volumes

Persistent storage used to preserve application data.

Volumes survive container recreation and upgrades.

Networks

Virtual networking layer that enables communication between containers and external systems.


Core Concepts

Image

A packaged application template.

Examples:

  • Web Server
  • Database Server
  • Monitoring Platform

Images are immutable.

Container

A running instance of an image.

Containers can be:

  • Started
  • Stopped
  • Restarted
  • Removed
  • Recreated

Volume

Persistent data storage.

Used for:

  • Databases
  • Configuration Files
  • Application Data
  • User Uploads

Network

Communication layer between containers.

Common network types:

  • Bridge
  • Host
  • Overlay
  • Custom User Networks

Installation

Supported Platforms

  • Debian
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • AlmaLinux
  • Fedora

Verify Installation

docker version
docker info

Verify service status:

systemctl status docker

Container Lifecycle

Create and Run

docker run nginx

List Running Containers

docker ps

List All Containers

docker ps -a

Stop Container

docker stop <container>

Start Container

docker start <container>

Restart Container

docker restart <container>

Remove Container

docker rm <container>

Persistent Storage

Containers should remain stateless whenever possible.

Application data should be stored externally using:

  • Docker Volumes
  • Bind Mounts
  • Network Storage

Examples:

  • NFS
  • SMB
  • Distributed Storage

Benefits

  • Easier upgrades
  • Faster recovery
  • Data survives container replacement

Docker Networking

Docker provides virtual networking capabilities.

Common Use Cases

  • Frontend to Backend Communication
  • Application to Database Communication
  • Reverse Proxy Routing
  • Service Discovery

Useful Commands

docker network ls
docker network inspect <network>

Docker Compose

Docker Compose allows infrastructure to be defined as code.

Benefits

  • Repeatable deployments
  • Version-controlled configurations
  • Easier maintenance
  • Multi-container orchestration

Example Use Cases

  • Web Application + Database
  • Monitoring Stack
  • File Synchronization Platform
  • Development Environments

Operations

Logs

View container logs:

docker logs <container>

Follow logs in real time:

docker logs -f <container>

Access a Running Container

docker exec -it <container> bash

or

docker exec -it <container> sh

Backup and Recovery

Recommended Backup Targets

  • Docker Compose Files
  • Configuration Directories
  • Persistent Volumes
  • Database Dumps

Recovery Goals

  • Rebuild infrastructure quickly
  • Minimize downtime
  • Preserve application data

Security Best Practices

  • Use official images whenever possible.
  • Keep images updated.
  • Minimize exposed ports.
  • Use dedicated networks.
  • Avoid running containers as root.
  • Protect secrets and credentials.
  • Regularly review logs and updates.

Common Use Cases

Infrastructure

  • Reverse Proxies
  • DNS Services
  • VPN Gateways

Storage

  • File Synchronization Platforms
  • Object Storage
  • Backup Systems

Monitoring

  • Grafana
  • Prometheus
  • Uptime Monitoring

Databases

  • PostgreSQL
  • MariaDB
  • MySQL
  • Redis

Development

  • CI/CD Platforms
  • Source Control Services
  • Testing Environments

Recommended Learning Path

  1. Docker Fundamentals
  2. Images and Containers
  3. Volumes
  4. Networking
  5. Docker Compose
  6. Container Monitoring
  7. Backup and Recovery
  8. Security Best Practices
  9. Multi-Service Deployments
  10. Production Operations

Next Topics

  • Docker Installation on Debian
  • Docker Compose Deep Dive
  • Container Networking
  • Persistent Storage Design
  • Reverse Proxies
  • Monitoring Stack Deployment
  • Backup Strategies
  • Production Best Practices