DevOps

ยท

2 min read

Day 15 of DevOps Learning ๐Ÿš€:
Today, I began exploring Docker and its importance in the DevOps lifecycle. Here's a summary of the key topics covered:
๐Ÿ‘‰ Why Docker is Used?
- Docker is used to containerize applications, ensuring consistent environments across different platforms (development, testing, production).
It helps isolate dependencies, making applications more scalable and portable.
๐Ÿ‘‰ Key Docker Recipes:
1. Dockerfile:
- A Dockerfile is the blueprint for building Docker images. It's essential for creating container images in a reproducible way.

2. Key Commands in Dockerfile:
FROM: Specifies the base image to use.
MAINTAINER: Information about the maintainer of the image.
WORKDIR: Sets the working directory inside the container.
ARG: Defines build-time variables.
ENV: Sets environment variables.
RUN: Executes commands in the shell to set up the image.
ADD: Copies files from host to container, with auto-extraction support.
COPY: Similar to ADD but without auto-extraction.
CMD: Provides default commands to run in the container.
VOLUME: Creates a mount point with specified directories.
EXPOSE: Defines the ports the container listens on.
ENTRYPOINT: Sets the command to run as the container starts.

2. Multistage Dockerfile
A Multistage Dockerfile helps minimize image size by using multiple stages, each handling different tasks. This reduces redundancy.
Parent and child library concept: Code is split into stages to create smaller, more efficient images.

3. Docker Compose File
Docker Compose allows you to define and run multi-container Docker applications by using a simple .yml file to configure services, networks, and volumes.

๐Ÿ‘‰ DevOps Lifecycle with Docker:
The full process follows these steps:
Java/Python Application โ†’ JAR file using Maven โ†’ Image using Dockerfile โ†’ Container using Docker โ†’ Kubernetes Application.

๐Ÿ‘‰ Important Docker Commands:
Covered essential Docker commands, such as:
docker build: Builds an image from a Dockerfile.
docker run: Runs a container from an image.
docker pull: Downloads an image from a repository.
docker ps: Lists running containers.
docker stop: Stops a running container.

ย