Kritim Yantra
Apr 14, 2025
Docker has revolutionized software development by simplifying containerization—a lightweight alternative to traditional virtual machines. Whether you're a developer, DevOps engineer, or just curious about modern deployment practices, learning Docker is a valuable skill.
This guide will take you from Docker basics to advanced concepts, with hands-on examples and best practices.
Docker is an open-source platform that allows you to package applications and their dependencies into containers. These containers are lightweight, portable, and run consistently across different environments.
nginx
, ubuntu
). ✅ Consistency: Works the same on any machine.
✅ Isolation: Apps run in separate environments.
✅ Efficiency: Containers share the host OS kernel (unlike VMs).
✅ Scalability: Easily deploy multiple instances.
sudo apt update && sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
docker --version
docker run hello-world # Test a sample container
Command | Description |
---|---|
docker pull <image> |
Download an image (e.g., docker pull nginx ) |
docker images |
List downloaded images |
docker run <image> |
Start a container |
docker ps |
List running containers |
docker stop <container> |
Stop a container |
docker rm <container> |
Remove a container |
docker rmi <image> |
Remove an image |
docker run -it ubuntu bash # Interactive shell
exit # Leave the container
A Dockerfile defines how to build a custom image.
# Use an official Python image
FROM python:3.9-slim
# Set working directory
WORKDIR /app
# Copy requirements and install
COPY requirements.txt .
RUN pip install -r requirements.txt
# Copy the app code
COPY . .
# Run the app
CMD ["python", "app.py"]
docker build -t my-python-app . # Build the image
docker run -p 5000:5000 my-python-app # Run with port mapping
docker volume create my_volume
docker run -v my_volume:/data nginx
docker run -v $(pwd):/app nginx # Sync host ↔ container
docker run -p 8080:80 nginx # Access at http://localhost:8080
docker network create my_network
docker run --network my_network my-app
Define services in docker-compose.yml
:
version: '3'
services:
web:
build: .
ports: ["5000:5000"]
redis:
image: "redis"
docker-compose up # Start all services
docker-compose down # Stop and remove
root
. Docker simplifies development and deployment by providing a consistent environment. Start with basic commands, move to Dockerfiles, then explore Compose and orchestration tools.
Happy containerizing! 🐳
Transform from beginner to Laravel expert with our personalized Coaching Class starting June 19, 2025. Limited enrollment ensures focused attention.
1-hour personalized coaching
Build portfolio applications
Industry-standard techniques
Interview prep & job guidance
Complete your application to secure your spot
Thank you for your interest in our Laravel mentorship program. We'll contact you within 24 hours with next steps.
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google