Docker + Django in 10 Days: From Zero to Production [Day: 02]
![Docker + Django in 10 Days: From Zero to Production [Day: 02]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1769543471246%2Fbf3b767c-7416-4c19-a0f7-240c6240a855.png&w=3840&q=75)
π― Goal of Day 2
By the end of today, you will:
Clearly understand Images vs Containers (practically)
Run your first Docker container
Learn the most important Docker commands
See how Docker actually works on your machine
Today is hands-on, but still beginner-friendly.
π Quick Recap from Day 1 (30 seconds)
Image = blueprint π§±
Container = running app π
Dockerfile = recipe π
Docker = consistent environment everywhere
Keep this in mind as we move.
π§ Image vs Container (Real Example)
Letβs say:
Image:
python:3.12Container: Python running in your terminal
You can:
Create 100 containers from 1 image
Delete containers β image still stays
π Your First Docker Command
Open your terminal and run:
docker run hello-world
What just happened?
Docker did this automatically:
Looked for
hello-worldimage locallyDidnβt find it
Downloaded it from Docker Hub
Created a container
Ran it
Printed a message
Exited
π Congrats β you just ran your first container
π Docker Hub (Very Important)
Docker Hub is like GitHub for Docker images
Website:
https://hub.docker.com/
Examples:
pythonpostgresredisnginx
Youβll use these a LOT in Django-DRF.
π§ͺ Running a Real Container (Python Example)
Run this:
docker run -it python:3.12
What this means:
-itβ interactive terminalpython:3.12β image name + version
Youβll enter a Python shell inside a container π
Try inside it:
print("Hello from Docker")
Exit Python:
exit()
Exit container:
exit
π¦ Important Docker Commands (Must Know)
π See Images
docker images
π See Running Containers
docker ps
π See All Containers (even stopped)
docker ps -a
βΆοΈ Run a Container
docker run image_name
Example:
docker run python:3.12
π Stop a Running Container
docker stop <container_id>
β Remove a Container
docker rm <container_id>
β Remove an Image
docker rmi <image_id>
β οΈ You must stop & remove containers first.
π§ Very Important Concept: Containers Are Ephemeral
When a container stops, its data is gone (by default).
Example:
You install something inside container
Stop it
Run a new container
Itβs clean again
π Solution (later days):
Volumes
Bind mounts
π§© How This Relates to Django-DRF
In Django terms:
Image β Django app template
Container β Running Django server
Rebuild image β Code/environment changes
Soon, youβll do:
docker run django_app
Instead of:
python manage.py runserver
π§ Mental Model Update
Today you learned this loop:
docker run β container starts
container stops β container is gone
image stays β reusable
This is the heart of Docker.
π Official Docs (Short Reads)
Docker run command
https://docs.docker.com/engine/reference/commandline/run/Docker Hub
https://docs.docker.com/docker-hub/
Bookmark them β donβt memorize.
π Homework for Day 2
Run:
docker run hello-worldRun Python container:
docker run -it python:3.12Check:
docker images docker ps -aStop & remove at least one container manually
β οΈ Common Beginner Mistakes
Forgetting to remove stopped containers
Thinking containers store data permanently
Panic when container exits π (itβs normal)
β End of Day 2 Summary
You ran real containers
You understand images vs containers practically
You learned essential Docker commands
Youβre ready to build images next
![Docker + Django in 10 Days: From Zero to Production [Day: 07]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fuploads%2Fcovers%2F696fcd472484e6d591510582%2F911a802d-c837-4cb6-b3fc-73966aff1020.png&w=3840&q=75)
![Docker + Django in 10 Days: From Zero to Production [Day: 06]](/_next/image?url=https%3A%2F%2Fcloudmate-test.s3.us-east-1.amazonaws.com%2Fuploads%2Fcovers%2F696fcd472484e6d591510582%2Fa53f784c-27e6-4611-8627-a7d76fe9875b.png&w=3840&q=75)
![Docker + Django in 10 Days: From Zero to Production [Day: 05]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1770578634367%2F8708279a-574a-4250-b12b-22d01fe91841.png&w=3840&q=75)
![Docker + Django in 10 Days: From Zero to Production [Day: 04]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1770151845620%2F77951891-5216-4440-aab8-7b848b6eba8f.png&w=3840&q=75)
![Docker + Django in 10 Days: From Zero to Production [Day: 03]](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1769895181687%2Fdd60bdd1-f050-4f82-8e47-dde4a70f7798.png&w=3840&q=75)