This guide covers essential Docker commands and concepts, including:
- Building images
- Running containers
- Managing processes
- Cleaning up resources
It provides a clear understanding of the core Docker workflow with simple examples, enabling you to start building and running containerized applications confidently.
1. Build Docker Image
Create the image from your Dockerfile:
docker build -imagename(anyname) .
2. Run Docker Container
Start a container from the image:
docker run -p 3000:3000 imagename(anyname)
Port mapping:
3000:3000= local machine → container
3. List Containers
docker ps -a
Shows all containers (running + stopped)
4. Stop a Running Container
docker stop <container_id>
5. Remove a Container.
docker rm <container_id>
6. Remove Docker Image.
By name:
bash docker rmi dirname
### By image ID:
```bash
docker rmi <image_id>
Quick Flow (Important to remember)
build → run → list → stop → remove container → remove image
