Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐳 My Docker Learning Journey

From zero to containerizing Python, React, Node.js & full-stack MERN apps β€” my complete Docker beginner notes.

πŸ“Ί Tutorial followed: Docker Masterclass by Adomic Arts


πŸ“ Project Structure

docker-demo/
β”œβ”€β”€ Dockerfile        # My first Dockerfile β€” containerizing a Python app
β”œβ”€β”€ python/
β”‚   └── demo.py       # Python script that runs inside the container
└── html/
    └── ...           # HTML files copied into the container

πŸ“š What I Learned

🧱 1. What is Docker?

Docker packages your app and everything it needs into a container β€” it runs the same way on any machine. No more "it works on my computer" problems!

  • A Docker Image = the blueprint / recipe
  • A Docker Container = a running instance of that image
  • Containers are NOT full operating systems like VMs β€” they run one specific task

πŸ“„ 2. Writing a Dockerfile

My very first Dockerfile (Python app):

FROM python

WORKDIR /user/app/src

COPY html /var/

COPY python/demo.py /user/app/src/

CMD ["python", "/user/app/src/demo.py"]
Instruction What it does
FROM Choose a base image to start from
WORKDIR Set the working directory inside the container
COPY Copy files from my machine into the container
RUN Run a command while building the image
EXPOSE Tell Docker which port the app uses
CMD The command that runs when the container starts

βš™οΈ 3. Essential Docker Commands

# Build an image from the Dockerfile
docker build -t image_name .

# Run a container
docker run --name container_name image_name

# Run in detached mode (background)
docker run --name container_name -d image_name

# List running containers
docker ps

# List ALL containers (including stopped)
docker ps -a

# Stop a running container
docker stop container_name

# Remove a stopped container
docker rm container_name

# List all images
docker images

# Remove an image (remove its containers first!)
docker rmi image_name

# Pull an image without running it
docker pull image_name

# Run a command inside a running container
docker exec container_name command

# Attach to a background container
docker attach container_id

# Remove EVERYTHING (containers, images, volumes)
docker system prune -a

🌐 4. Port Mapping

To access an app running inside a container, map a host port to the container port:

docker run --name container_name -p 3000:5173 image_name
#                                    ↑       ↑
#                               host port  container port

🏷️ 5. Image Versioning with Tags

Docker lets you version images using tags:

# Build with a tag
docker build -t image_name:v1 .

# Run a specific version
docker run --name container_name -p 3000:4000 image_name:v1

πŸ“¦ 6. Docker Volumes β€” Persisting Data

Containers lose data when they stop. Volumes solve this by persisting data outside the container.

Types of Volumes:

Anonymous Volume β€” temporary, no name:

docker run -d --name my_container -v /app/data my_image

Named Volume β€” persists across restarts, shareable:

docker run -d --name my_container -v my_volume:/app/data my_image

Bind Mount (Host Volume) β€” maps a folder on your machine directly:

docker run -d --name my_container -v /path/on/host:/path/in/container my_image

Volume Commands:

docker volume create my_volume      # Create a volume
docker volume ls                    # List all volumes
docker volume inspect my_volume     # Inspect a volume
docker volume rm my_volume          # Remove a volume

Live Development with Volumes:

docker run --name container_name -p 3000:5173 --rm \
  -v /app/node_modules \
  -v ${PWD}:/app \
  -e CHOKIDAR_USEPOLLING=true \
  image_name

--rm automatically removes the container when it stops ✨


πŸ—‚οΈ 7. .dockerignore

Like .gitignore β€” tells Docker what NOT to copy into the image. Speeds up builds and keeps sensitive files out:

node_modules
.env
.git

πŸš€ 8. Dockerizing Different Apps

Simple Node.js App

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5000
CMD ["npm", "start"]

React App (Vite)

FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 5173
CMD ["npm", "run", "dev"]

πŸ—οΈ 9. Docker Compose β€” Multi-Container Apps

Docker Compose lets you define and run multiple containers together using a single docker-compose.yml file.

Example β€” Full Stack MERN app with MongoDB + API + Client:

services:
  mongo:
    image: mongo:latest
    container_name: mongo_container
    volumes:
      - mongo_data:/data/db
    ports:
      - "27017:27017"

  api:
    build: ./api
    container_name: api_container
    ports:
      - "5000:5000"
    depends_on:
      - mongo
    volumes:
      - ./api:/app
      - /app/node_modules
    environment:
      - MONGO_URL=mongodb://mongo:27017/test-users

  client:
    build: ./client
    container_name: client_container
    ports:
      - "3000:3000"
    depends_on:
      - api
    stdin_open: true
    tty: true
    volumes:
      - ./client:/app
      - /client/node_modules

volumes:
  mongo_data:

depends_on ensures services start in the right order πŸ”—


☁️ 10. Pushing Images to Docker Hub

Share your images with the world!

docker login
docker tag image_name dockerhub_username/image_name:tag
docker push dockerhub_username/image_name:tag

πŸ—ΊοΈ My Learning Path

What is Docker?
      ↓
Write first Dockerfile (Python app)
      ↓
docker build & docker run
      ↓
Port mapping for web apps
      ↓
Image versioning with tags
      ↓
Docker Volumes for data persistence
      ↓
Dockerize React & Node apps
      ↓
Docker Compose for MERN stack πŸŽ‰
      ↓
Push to Docker Hub ☁️

πŸ”œ What's Next

  • Docker networking (custom networks between containers)
  • Multi-stage builds for smaller production images
  • Docker secrets for managing sensitive data
  • Introduction to Kubernetes

πŸ† Certificate

This repo is part of my Docker learning journey. I successfully completed the Crash Course: Docker For Absolute Beginners on KodeKloud!

Field Details
πŸŽ“ Course Crash Course: Docker For Absolute Beginners
🏫 Platform KodeKloud
πŸ‘€ Instructor Mumshad Mannambeth (Founder & Trainer)
πŸ“… Completed July 16, 2026
πŸͺͺ Certificate ID 4db32d82-07f0-49b9-9ef2-27db18123a7a

πŸ“– Resources


This is my first Docker experience β€” built with curiosity, lots of terminal errors, and even more learning! πŸš€

About

🐳 My first Docker project β€” built to learn Docker basics: images, containers, layers, core commands, volumes, and Docker Compose.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages