1. Traditional Deployment Issues
- Physical Servers:
- No resource boundaries for applications.
- Multiple apps on one server could lead to resource hogging, causing underperformance.
- Solution: Run each app on a separate server.
- Problem: Underutilized resources, expensive to maintain multiple servers.
2. Virtualization
- Definition: Creation of virtual versions of OS, servers, storage, or network resources using software to simulate hardware.
- Benefits:
- Run multiple OS and apps on a single server.
- Types:
- Network Virtualization: Divides bandwidth into secure, assignable channels for improved speed, availability, and security.
- Storage Virtualization: Pools multiple storage devices into a single, centrally managed device.
- Benefits: Remote storage appears local, combines smaller volumes, improves reliability/performance, high availability, disaster recovery.
- Data Virtualization: Aggregates data from various sources into a single, logical view.
- Benefits: Abstracts technical details (location, structure), connects multiple sources, federates data, delivers as requested.
- Desktop Virtualization: Isolates desktop OS from endpoint, enables remote access, supports shared hosted desktops (e.g., Microsoft Remote Desktop Services).
- Application Virtualization: Runs apps separately from the accessing device.
- Others: Hardware, OS, Containerization.
3. Docker Containers
- Definition: A running instance of a Docker image, containing one or more processes in a self-contained, isolated environment.
- Key Points:
- Wraps application, dependencies, networking, and volumes.
- Cannot modify the original image.
- Stored in
/var/lib/docker/containers
.
- Basic Operations:
- Create, start, run, list (running/all), inspect, stop, delete containers.
- Attaching to Containers:
- Attach: Connects to a container with one input/output stream.
- Exec: Runs a command inside a container (e.g.,
docker exec <container> <command>
).
- Hostname and Naming:
- Hostname: First 12 characters of container ID (check with
hostname
inside container).
- Name: Randomly generated by Docker.
- Port Publishing:
- Required for external access to container apps.
- Set at container creation (e.g.,
docker run -p 8080:80 httpd
).
- Cannot update ports on a running container.
4. Docker Images
- Definition: Read-only instructions to run containers, composed of layers.
- Storage: Held in repositories within a Docker registry (e.g., Docker Hub).
- Layered File System:
- Uses UnionFS; updates add new layers.
- Changes in a running container are written to a writable layer.
- Example: Base (Ubuntu) → Update apt cache → Apache (httpd).
- Creating Custom Images:
- Commit: Save changes from a running container (e.g., create directory/file, then commit).
- Dockerfile: Define image with instructions.
- Dockerfile Instructions:
FROM
, ENV
, RUN
, CMD
, EXPOSE
, WORKDIR
, ADD
, COPY
, LABEL
, MAINTAINER
, ENTRYPOINT
.
- Each instruction adds a layer, processed top-to-bottom.
5. Container Orchestration