This repository contains a comprehensive guide to Docker π³, covering essential concepts, hands-on demonstrations, and advanced features like Docker Compose, Networking, and Image Management.
π Understanding Docker and its importance in software development.
π Difference between Docker Images and Containers.
π Basic Docker commands and key concepts.
π‘ Challenges in traditional software development workflows.
π‘ How Docker resolves dependency conflicts and ensures a consistent environment.
πΉ What are Containers?
πΉ How Docker Images act as blueprints for containers.
πΉ Portability ποΈ and Scalability π benefits.
π§ Installing Docker Desktop.
π§ Running containers (docker run
, docker ps
, docker stop
).
π§ Managing images (docker pull
, docker rmi
).
π Port Binding & Networking between containers.
π οΈ Troubleshooting (docker logs
, docker exec
).
βοΈ Differences between Docker & Virtual Machines.
π» Using Docker for small-scale projects and team collaborations.
π οΈ Building a Node.js π’ app with MongoDB inside Docker containers.
π’οΈ Running MongoDB inside a container.
π Using Docker Networks for seamless container communication.
π Running Mongo Express as a UI for MongoDB.
βοΈ Simplifying multi-container applications.
π Writing docker-compose.yml
for MongoDB & Mongo Express.
πΎ Handling data persistence with Docker Volumes.
π¦ Creating Dockerfiles to package applications.
πΌοΈ Understanding base images and configuring environment variables.
π Building and running custom Docker images.
π€ Creating a Docker Hub account.
π₯ Pushing and pulling Docker Images.
π Docker Networking concepts and Container Communication.
Ensure you have the following installed:
β
Docker Desktop
β
Docker CLI
β
Docker Hub Account (Optional for image hosting)
git clone https://github.com/Hifza-Khalid/docker-complete-guide.git
cd docker-complete-guide
docker run --name mongodb -d -p 27017:27017 mongo
docker run --name mongo-express -d -p 8081:8081 --link mongodb:mongo mongo-express
docker ps
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
Create and run an application container using a custom Dockerfile:
docker build -t my-app .
docker run -d -p 3000:3000 my-app
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
π A PDF containing all essential Docker commands is included in this repository for quick reference.
πΉ 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
π Contributions are welcome! Submit pull requests for enhancements, bug fixes, or additional examples.
π This project is licensed under the MIT License.
π© For queries or discussions, open an issue or reach out via GitHub discussions.