Docker
when u dont have time atleast go though this points
docker architeecture
how to buld docker image
manage docker
docker networking
docker volume
docker compose
VM has its own kernel + OS → heavier, slower boot.
Container shares host kernel, isolates via namespaces/cgroups → faster, lightweight, but less isolation than VM.
How to enable communication by container name
You need to create a user-defined bridge network:
“How do containers in the same Docker network talk to each other?” Answer: Through embedded DNS service → container names resolve automatically (no need for IPs).
note: can communicate with other container with container ip without custom network✅ Problem Statement: Why Do We Need Docker?
In traditional development environments:
Applications run differently across developers’ machines, test, and production due to inconsistent setups ("it works on my machine" issue).
Installing and configuring dependencies is time-consuming and error-prone.
Managing multiple applications or versions on the same machine leads to conflicts.
Setting up isolated environments for each service is complex and resource-heavy.
Deployment is often manual, inconsistent, and difficult to scale or replicate.
🛠️ Solution: What Docker Offers
Docker is an open-source containerization platform that allows you to package applications with their dependencies into isolated units called containers.
Key benefits:
Portability: Containers run the same way on any machine — development, testing, or production.
Lightweight: Uses OS-level virtualization, making it faster and more efficient than traditional VMs.
Isolation: Runs each service in its own container without interfering with others.
Consistency: Define environment and dependencies in a
Dockerfile; shareable and version-controlled.Faster onboarding: Developers can start with a working environment using
docker-compose up.Simplified deployment: Easily deploy containers to Kubernetes, cloud platforms, or CI/CD pipelines.
Supports microservices architecture by allowing each component to run in its own container.
Volumes vs Bind Mounts
Volumes: Managed by Docker, stored under
/var/lib/docker/volumes/.use to bind database data
Bind Mounts: Maps exact host path → container. Good for dev, bad for prod security.
use to mount app config
Compose = local dev, small setups.
Kubernetes = production, large scale, HA, service discovery across nodes.
Component
Simple Definition
FROM
Sets the base image for your Docker image (e.g., FROM ubuntu:20.04).
RUN
Executes commands in the container during the image build process (e.g., installing packages).
CMD
Sets the default command to run when the container starts (can be overridden).
ENTRYPOINT
Sets a command that always runs when the container starts (more strict than CMD).
COPY
Copies files/directories from your local system into the image.
ADD
Like COPY but also supports URLs and auto-extracts tar files.
WORKDIR
Sets the working directory for the following instructions (like cd in shell).
ENV
Sets environment variables inside the container.
EXPOSE
Documents the port that the container will listen on (doesn't actually open it).
VOLUME
Defines mount points to persist data or share data between containers.
USER
Sets which user the container should run as (default is root).
LABEL
Adds metadata to the image (e.g., version, maintainer).
ARG
Defines build-time variables — can be used only during image build.
HEALTHCHECK
Tells Docker how to test if a container is healthy (e.g., checking if a web server is up).
SHELL
Changes the default shell used in RUN (used for Windows containers or special cases).
ONBUILD
Adds a trigger that runs instructions when a child image is built — useful for base images.
STOPSIGNAL
Sets the system signal used to stop the container (default is SIGTERM).
Last updated