0% found this document useful (0 votes)
4 views2 pages

DevOps Notes - Docker & Containers

Docker is a containerization platform that packages applications with their dependencies into containers, ensuring consistent performance across environments. Key concepts include images, containers, Dockerfiles, and Docker Compose, which facilitate the management of multi-container applications. Best practices emphasize using lightweight images, maintaining clean images, and utilizing Docker volumes for data persistence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

DevOps Notes - Docker & Containers

Docker is a containerization platform that packages applications with their dependencies into containers, ensuring consistent performance across environments. Key concepts include images, containers, Dockerfiles, and Docker Compose, which facilitate the management of multi-container applications. Best practices emphasize using lightweight images, maintaining clean images, and utilizing Docker volumes for data persistence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DevOps Notes – Docker & Containers

Prepared by Sathish Kumar

Introduction
Docker is a containerization platform that enables developers to package applications
along with all dependencies into a standardized unit called a container. Containers ensure
consistent performance across different environments, from development to production.
They help DevOps teams achieve scalability, isolation, and faster deployments.

Key Concepts
1. **Image:** A lightweight, standalone package that includes everything needed to run an
application. 2. **Container:** A running instance of an image that isolates applications
from the host system. 3. **Dockerfile:** A text file containing instructions to build a Docker
image. 4. **Docker Engine:** The core component that runs and manages containers. 5.
**Docker Hub:** A cloud-based registry for storing and sharing Docker images. 6.
**Docker Compose:** A tool to define and manage multi-container applications using
YAML files.

Common Docker Commands


• `docker --version` – Check installed Docker version. • `docker build -t .` – Build a Docker
image. • `docker images` – List available images. • `docker run -d -p 8080:80 ` – Run a
container in detached mode. • `docker ps -a` – List all containers. • `docker logs ` – View
container logs. • `docker stop ` – Stop a running container. • `docker rm ` – Remove a
stopped container. • `docker rmi ` – Delete an image.

Real-World Example
In a DevOps workflow, Docker is often used to containerize microservices. For example, a
web application may have separate containers for frontend, backend, and database. Using
Docker Compose, you can define all services in a `docker-compose.yml` file, allowing the
entire application stack to be deployed with a single command (`docker-compose up`).

Best Practices
1. Use lightweight base images (e.g., Alpine Linux) to reduce image size. 2. Keep images
clean by removing unnecessary dependencies. 3. Use `.dockerignore` files to exclude files
not needed in images. 4. Tag images properly (e.g., app:v1.0). 5. Avoid storing secrets in
images; use environment variables or secret managers. 6. Use Docker volumes for
persistent data storage.
Interview Questions and Answers
1. **What is Docker and why is it used?** Docker allows packaging applications and
dependencies together to ensure consistency across environments. 2. **Difference
between an image and a container?** An image is a template; a container is a running
instance of that image. 3. **What is a Dockerfile?** A Dockerfile is a script with instructions
to build a Docker image automatically. 4. **How is Docker different from a virtual
machine?** Containers share the host OS kernel, while VMs include a full OS for each
instance. 5. **How do you persist data in Docker?** Use Docker volumes or bind mounts.
6. **What is Docker Compose used for?** It manages multi-container applications using
YAML configuration. 7. **How do you monitor running containers?** Use `docker stats` or
integrate with monitoring tools like Prometheus and Grafana. 8. **What is Docker Hub?**
A central repository for sharing and downloading Docker images. 9. **How do you
troubleshoot container issues?** Use `docker logs ` and `docker inspect ` to identify
problems.

Summary
Docker revolutionized the way applications are developed and deployed. By isolating
applications and their dependencies, it ensures consistency, scalability, and portability
across environments. It has become an essential tool in DevOps for building, shipping,
and running applications efficiently.

You might also like