00. Docker Prerequisites
Before diving into Docker containerization, it is highly recommended to have a solid understanding of fundamental system administration and networking concepts. Containers are heavily reliant on the underlying Linux kernel and network stack.
Here is a practical breakdown of the prerequisites you should be comfortable with before starting Docker.
Linux Fundamentals
Section titled “Linux Fundamentals”Since Docker natively utilizes Linux kernel features (like namespaces and cgroups) to isolate containers, understanding how Linux operates is crucial.
Processes
Section titled “Processes”A container is fundamentally just a regular Linux process that is isolated from the rest of the system.
- Concepts: Process IDs (PIDs), background vs foreground processes, signals (SIGKILL, SIGTERM).
- Commands:
ps,top,htop,kill.
Filesystems
Section titled “Filesystems”Docker uses layered filesystems to build images.
- Concepts: The Linux directory structure (
/etc,/var,/home), mounting drives, symlinks. - Commands:
ls,cd,pwd,df -h,mount.
Users & Groups
Section titled “Users & Groups”Containers often run as the root user by default, which can be a security risk. Understanding Linux permissions is key to securing containers.
- Concepts: UID (User ID), GID (Group ID), the
/etc/passwdfile,rootvs standard users. - Commands:
id,whoami,useradd,usermod.
Permissions
Section titled “Permissions”When mapping volumes from your host machine into a Docker container, file permissions dictate whether the container can read or write to those files.
- Concepts: Read (
r), Write (w), Execute (x), owner/group/others, octal notation (e.g.,755,644). - Commands:
chmod,chown.
Environment Variables
Section titled “Environment Variables”Environment variables are the primary way we pass configuration (like database passwords or API keys) into a Docker container at runtime.
- Concepts:
$PATH, system-wide vs user-specific variables. - Commands:
export,echo $VAR_NAME,printenv.
Networking Basics
Section titled “Networking Basics”Containers need to communicate with each other and the outside world. Networking fundamentals are required to expose container ports and link services.
A port is a logical endpoint for communication. When a web server container runs, it binds to a specific port.
- Concepts: Well-known ports (80 for HTTP, 443 for HTTPS, 22 for SSH, 5432 for PostgreSQL).
- Docker Context: You will frequently “map” a port on your host machine to a port inside the container (e.g.,
-p 8080:80).
TCP/IP Basics
Section titled “TCP/IP Basics”The foundational protocols of the internet.
- Concepts: IP Addresses (IPv4, IPv6), localhost (
127.0.0.1), subnets. Docker creates its own virtual bridge network and assigns internal IP addresses to containers.
DNS Basics
Section titled “DNS Basics”Domain Name System translates human-readable domain names to IP addresses.
- Concepts: DNS resolution,
/etc/hosts. - Docker Context: Docker provides internal DNS resolution so containers can communicate using their container names instead of IP addresses.
HTTP/HTTPS Basics
Section titled “HTTP/HTTPS Basics”The protocols used for web traffic.
- Concepts: HTTP Methods (GET, POST), Status Codes (200, 404, 500), SSL/TLS certificates.
- Docker Context: You will often deploy reverse proxies (like Nginx) in Docker to route HTTP traffic and terminate HTTPS.
Essential Tools
Section titled “Essential Tools”SSH (Secure Shell)
Section titled “SSH (Secure Shell)”Most Docker deployments happen on remote Linux servers. You must know how to securely connect to these servers.
- Concepts: SSH keys (public/private keypairs), passwordless authentication, the
~/.ssh/authorized_keysfile. - Commands:
ssh user@ip,ssh-keygen.
Git Fundamentals
Section titled “Git Fundamentals”Infrastructure as Code (IaC) and containerization go hand-in-hand. Your Dockerfiles and configurations will always be stored in version control.
- Concepts: Repositories, commits, branches, pushing/pulling.
- Commands:
git clone,git commit,git push,git pull.