Skip to content

A comprehensive guide to Docker 🐳, covering fundamental concepts πŸ“–, practical commands πŸ› οΈ, Docker Compose βš™οΈ, networking 🌐, image management πŸ–ΌοΈ, and real-world application deployment πŸš€.

Notifications You must be signed in to change notification settings

Hifza-Khalid/docker-complete-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

πŸš€ Docker Complete Guide

πŸ“Œ Overview

This repository contains a comprehensive guide to Docker 🐳, covering essential concepts, hands-on demonstrations, and advanced features like Docker Compose, Networking, and Image Management.


πŸ“š Topics Covered

πŸ”Ή Introduction to Docker

πŸ“Œ Understanding Docker and its importance in software development.
πŸ“Œ Difference between Docker Images and Containers.
πŸ“Œ Basic Docker commands and key concepts.

πŸ”Ή Why Docker?

πŸ’‘ Challenges in traditional software development workflows.
πŸ’‘ How Docker resolves dependency conflicts and ensures a consistent environment.

πŸ”Ή Docker Containers & Images

πŸ”Ή What are Containers?
πŸ”Ή How Docker Images act as blueprints for containers.
πŸ”Ή Portability πŸ—οΈ and Scalability πŸš€ benefits.

πŸ”Ή Practical Docker Setup & Commands

πŸ”§ Installing Docker Desktop.
πŸ”§ Running containers (docker run, docker ps, docker stop).
πŸ”§ Managing images (docker pull, docker rmi).

πŸ”Ή Advanced Docker Features

🌍 Port Binding & Networking between containers.
πŸ› οΈ Troubleshooting (docker logs, docker exec).
βš–οΈ Differences between Docker & Virtual Machines.

πŸ”Ή Docker in Application Development

πŸ’» Using Docker for small-scale projects and team collaborations.
πŸ› οΈ Building a Node.js 🟒 app with MongoDB inside Docker containers.

πŸ”Ή Docker Databases & Networking

πŸ›’οΈ Running MongoDB inside a container.
πŸ”— Using Docker Networks for seamless container communication.
πŸ“Š Running Mongo Express as a UI for MongoDB.

πŸ”Ή Docker Compose

βš™οΈ Simplifying multi-container applications.
πŸ“ Writing docker-compose.yml for MongoDB & Mongo Express.
πŸ’Ύ Handling data persistence with Docker Volumes.

πŸ”Ή Dockerizing Applications

πŸ“¦ Creating Dockerfiles to package applications.
πŸ–ΌοΈ Understanding base images and configuring environment variables.
πŸš€ Building and running custom Docker images.

πŸ”Ή Pushing Images to Docker Hub

πŸ“€ Creating a Docker Hub account.
πŸ“₯ Pushing and pulling Docker Images.
🌐 Docker Networking concepts and Container Communication.


πŸš€ Getting Started

πŸ”Ή Prerequisites

Ensure you have the following installed:
βœ… Docker Desktop
βœ… Docker CLI
βœ… Docker Hub Account (Optional for image hosting)


πŸ”Ή Clone the Repository

git clone https://github.com/Hifza-Khalid/docker-complete-guide.git
cd docker-complete-guide

πŸ—οΈ Running the Example Application

1️⃣ Run MongoDB in a Docker Container

docker run --name mongodb -d -p 27017:27017 mongo

2️⃣ Run Mongo Express for MongoDB Management

docker run --name mongo-express -d -p 8081:8081 --link mongodb:mongo mongo-express

3️⃣ Verify Running Containers

docker ps

⚑ Using Docker Compose

Run the following command to start MongoDB & Mongo Express using Docker Compose:

docker-compose up -d

Here’s a sample docker-compose.yml file:

version: '3'
services:
  mongodb:
    image: mongo
    container_name: mongodb
    ports:
      - "27017:27017"

  mongo-express:
    image: mongo-express
    container_name: mongo-express
    ports:
      - "8081:8081"
    environment:
      - ME_CONFIG_MONGODB_SERVER=mongodb

πŸ—οΈ Building a Custom Docker Image

Create and run an application container using a custom Dockerfile:

docker build -t my-app .
docker run -d -p 3000:3000 my-app

πŸ“€ Pushing to Docker Hub

Replace your-dockerhub-username with your actual Docker Hub username before running these commands:

docker tag my-app Hifza-Khalid/docker-complete-guide
docker push Hifza-Khalid/docker-complete-guide

πŸ› οΈ Docker Commands Cheat Sheet

πŸ“„ A PDF containing all essential Docker commands is included in this repository for quick reference.


⚠️ Troubleshooting Common Issues

πŸ”Ή Port Already in Use Error
❌ Error: bind: address already in use
βœ… Fix: Stop and remove the conflicting container:

docker stop <container_id> && docker rm <container_id>

πŸ”Ή Docker Daemon Not Running
❌ Error: Cannot connect to the Docker daemon
βœ… Fix: Start the Docker service:

sudo systemctl start docker

πŸ”Ή Image Pull Failure
❌ Error: Error response from daemon: pull access denied
βœ… Fix: Ensure you're logged in to Docker Hub:

docker login

πŸ“ Contributing

πŸš€ Contributions are welcome! Submit pull requests for enhancements, bug fixes, or additional examples.


πŸ“œ License

πŸ“„ This project is licensed under the MIT License.


πŸ“§ Contact

πŸ“© For queries or discussions, open an issue or reach out via GitHub discussions.

About

A comprehensive guide to Docker 🐳, covering fundamental concepts πŸ“–, practical commands πŸ› οΈ, Docker Compose βš™οΈ, networking 🌐, image management πŸ–ΌοΈ, and real-world application deployment πŸš€.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published