https://github.com/mohitjain0810/docker
This README contains essential project commands for installation, usage, testing, and deployment, ensuring users can easily set up and run the project. ๐
https://github.com/mohitjain0810/docker
docker docker-container docker-image docker-registry docker-swarm dockerfile dockerhub
Last synced: 8 months ago
JSON representation
This README contains essential project commands for installation, usage, testing, and deployment, ensuring users can easily set up and run the project. ๐
- Host: GitHub
- URL: https://github.com/mohitjain0810/docker
- Owner: mohitjain0810
- Created: 2025-06-02T12:31:19.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-06-02T12:46:23.000Z (8 months ago)
- Last Synced: 2025-06-03T01:33:16.095Z (8 months ago)
- Topics: docker, docker-container, docker-image, docker-registry, docker-swarm, dockerfile, dockerhub
- Language: Python
- Homepage:
- Size: 537 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ณ Ultimate Docker Guide & Command Reference


A complete Docker guide with **all essential commands**, from building images to managing containers and Docker Compose. Perfect for developers and teams to hit the ground running with containerization.
---
## ๐ What is Docker?
Docker is an open-source platform that packages applications and their dependencies into lightweight containers. Containers ensure consistency across development, testing, and production.
---
## ๐๏ธ Table of Contents
1. [โ
Verify Installation](#-verify-installation)
2. [๐ง Basic Docker Commands](#-basic-docker-commands)
3. [๐ฆ Image Management](#-image-management)
4. [๐ Container Management](#-container-management)
5. [๐ Docker Compose](#-docker-compose)
6. [๐งน Maintenance & Cleanup](#-maintenance--cleanup)
7. [๐ Troubleshooting & Debugging](#-troubleshooting--debugging)
8. [โ FAQ](#-faq)
---
## โ
Verify Installation
```bash
docker --version
docker-compose --version # For multi-container apps
```
---
## ๐ง Basic Docker Commands
```bash
# Pull an image from Docker Hub
docker pull
# Build an image from Dockerfile
docker build -t : .
# Run a container from an image
docker run -d -p : :
# List running containers
docker ps
# List all containers (including stopped)
docker ps -a
# Stop a running container
docker stop
# Start a stopped container
docker start
# Remove a stopped container
docker rm
# Remove an image
docker rmi :
# View container logs
docker logs
# Exec into a running container
docker exec -it sh
```
---
## ๐ฆ Image Management
```bash
# List local images
docker images
# Tag an image
docker tag : /:
# Push an image to Docker Hub
docker login
docker push /:
# Pull an image from Docker Hub
docker pull /:
# Remove unused images
docker image prune
# Remove all dangling (untagged) images
docker image prune -a
```
---
## ๐ Container Management
```bash
# Run a container with environment variables
docker run -d \
--name \
-p : \
-e "ENV_VAR=value" \
-v : \
:
# List all containers
docker ps -a
# Stop a container
docker stop
# Remove a container
docker rm
# Check container logs
docker logs
# Check resource usage
docker stats
# Inspect container metadata
docker inspect
```
---
## ๐ Docker Compose
Example docker-compose.yml:
```bash
version: "3.8"
services:
web:
build: .
ports:
- "5000:5000"
environment:
- ENV_VAR=value
depends_on:
- redis
redis:
image: redis:alpine
```
Common Docker Compose Commands
```bash
# Start services
docker-compose up -d
# Stop services
docker-compose down
# View logs
docker-compose logs
# Rebuild services
docker-compose up --build
# List services
docker-compose ps
```
---
## ๐งน Maintenance & Cleanup
```bash
# Remove unused containers, networks, images, and caches
docker system prune
# Remove all stopped containers
docker container prune
# Remove dangling (untagged) images
docker image prune
# Remove unused volumes
docker volume prune
# Remove all unused resources
docker system prune -a
```
---
## ๐ Troubleshooting & Debugging
```bash
# Port in use
lsof -i : && kill $(lsof -ti :)
# Permission issues
docker run --user $(id -u) ...
# Check logs
docker logs -f
# View container details
docker inspect
# Monitor container stats
docker stats
```
---
## โ FAQ
1. What is Docker?
- A platform to build, ship, and run applications in containers.
2. Why use Docker?
- Ensures consistency, portability, and scalability.
3. Where to use Docker?
- Development, testing, production, and CI/CD pipelines.