Docker all commands important tutorial
Here's a complete and updated Docker Commands Tutorial for Tech3Space with all important docker and docker compose commands, including docker ls related commands.
This tutorial is written in a clean, SEO-friendly format so you can directly use it as a blog post on your Tech3Space website.
Docker Commands Complete Tutorial for Tech3Space Next.js Project (2026)
Learn all essential Docker commands to build, run, manage, and debug your Tech3Space – a modern Next.js tech blog with Server Components, Shadcn/UI, Tailwind CSS, and SEO-optimized blog post pages.
This guide covers docker ls commands, build commands, compose commands, debugging, cleanup, and production tips.
1. Preparation Files (Must Have)
Make sure these files exist in your project root:
Dockerfile(multi-stage production build)docker-compose.yml(production setup)next.config.tswithoutput: 'standalone'
2. All Essential Docker Commands
Run these commands from the Tech3Space project folder.
Docker LS Commands (List Commands)
# List all running containers
docker ps
# List all containers (running + stopped)
docker ps -a
# List only container IDs (useful for scripting)
docker ps -q
# List all Docker images
docker images
# List images with filter (e.g., only Tech3Space images)
docker images | grep tech3space
# List detailed information about images
docker images --format "{{.Repository}}:{{.Tag}}\t{{.Size}}"
# List all volumes
docker volume ls
# List all networks
docker network ls
# List Docker system disk usage (very useful)
docker system df
Build Commands
# Build Docker image with a tag
docker build -t tech3space:latest .
# Build with no cache (use when you change dependencies or Dockerfile)
docker build --no-cache -t tech3space:latest .
# Build using Docker Compose
docker compose build
# Build with no cache using Compose
docker compose build --no-cache
Run & Start Commands
# Start containers in background (recommended for production)
docker compose up -d
# Start and build at the same time
docker compose up -d --build
# Start in foreground to see logs immediately
docker compose up
# Run a single container without compose
docker run -p 3000:3000 --name tech3space-app tech3space:latest
Logs & Monitoring Commands
# View logs of all services
docker compose logs
# Follow logs in real-time (most useful command)
docker compose logs -f
# View logs of specific service
docker compose logs tech3space
# View last 100 lines of logs
docker compose logs --tail=100
Stop & Remove Commands
# Stop all containers defined in docker-compose.yml
docker compose down
# Stop and remove volumes too (clean reset)
docker compose down -v
# Stop and remove images as well
docker compose down --rmi all
# Remove a specific container
docker rm tech3space-app
# Force remove a running container
docker rm -f tech3space-app
Debugging & Inspection Commands
# Enter inside the running container shell
docker exec -it tech3space-app sh
# Inspect container details
docker inspect tech3space-app
# Check real-time resource usage (CPU, Memory)
docker stats
# View container port mapping
docker port tech3space-app
Cleanup Commands (Very Important)
# Remove unused containers, networks, images, and build cache
docker system prune -f
# Remove all unused images (including dangling)
docker image prune -f
# Remove all stopped containers
docker container prune -f
# Remove all unused volumes
docker volume prune -f
# Full aggressive cleanup (use carefully)
docker system prune -a --volumes -f
Advanced & Production Commands
# Tag image for Docker Hub
docker tag tech3space:latest yourusername/tech3space:v1.0
# Push image to Docker Hub
docker push yourusername/tech3space:v1.0
# Pull latest image
docker pull yourusername/tech3space:latest
# Run one-time command inside container (example: build check)
docker compose run --rm tech3space npm run build
Complete Daily Workflow for Tech3Space
# 1. After making changes to your blog post page
docker compose build --no-cache
docker compose up -d
# 2. Check if container is running
docker ps
# 3. Check logs
docker compose logs -f
# 4. Test your SEO blog post
# Open: http://localhost:3000/blog/1
Testing SEO on Dockerized Tech3Space
After running the container:
- Visit
http://localhost:3000/blog/[slug] - Check page title, meta description, Open Graph tags, and JSON-LD
- Use tools like Google Rich Results Test
Your SEO-optimized blog post pages will render correctly thanks to Next.js Server Components running inside Docker.
Bonus Tips
- Always use
docker psfirst to check running containers. - Use
docker compose logs -fwhile developing. - Run
docker system prune -fweekly to save disk space. - For production, combine with Nginx reverse proxy in the same
docker-compose.yml.