Docker HandsOn π
This repository contains my hands-on practice and revision notes for Docker.
It includes commands, outputs, and experiments with images, containers, and networking.
- Practiced pulling and running Docker images (
nginx,python). - Explored container lifecycle: start, stop, remove, restart.
- Worked with port mapping (
-p 8080:80) to access services locally. - Used
docker execto interact with containers and create files/directories. - Learned about auto-removal containers (
--rm) and naming containers (--name). - Inspected container details using
docker inspect.
docker -vβ Check Docker versiondocker pull nginxβ Pull latest Nginx imagedocker image lsβ List available imagesdocker ps/docker ps -aβ List running/all containers
docker run nginx:latestβ Run Nginx interactivelydocker run -d nginxβ Run Nginx in detached modedocker run -d --rm --name nc -p 8080:80 nginxβ Run Nginx with auto-remove, custom name, and port mapping
docker stop <container_name>β Stop a containerdocker start <container_name>β Restart a stopped containerdocker rm <container_name>β Remove a containerdocker rm -f <container_name>β Force remove a running container
docker logs <container_name>β View container logsdocker logs -f <container_name>β Follow logs in real-timedocker inspect <container_name>β Inspect container details
-
docker exec -it <container_name> bashβ Open bash shell inside container -
cd /usr/share/nginx/htmlβ Navigate to Nginx default HTML directory -
Created custom directory and file:
docker exec nc mkdir rahul docker exec -it nc bash cd rahul touch rahul.txt
π Repo Structure Code docker_revision/
βββ README.md # Documentation (this file)
π Accessing Nginx
After running:
bash docker run -d --rm --name nc -p 8080:80 nginx Open http://localhost:8080 (localhost in Bing) in your browser to see the Nginx welcome page.