Lesson 1
Docker basics in plain language
This page focuses on the beginner questions first: what Docker is, why we use it, and how it helps keep apps consistent.
Docker is a tool that packages an application and the things it depends on so it can run the same way on different machines.
Layman version: Docker is like packing the full app setup into one ready-to-use box instead of carrying separate pieces.
- It reduces setup differences between systems.
- It avoids the āit works on my machineā problem.
- It keeps project dependencies separate.
- It makes development and deployment more predictable.
Basic Docker flow
1. Write appAdd your project files and code.
2. Define setupDescribe how the app should be packaged.
3. Build imageCreate a reusable blueprint.
4. Run containerStart the app in its own environment.
Image and container relationship
Image
The blueprint or template.
Container
The running instance created from that image.
Simple memory trick
Image = recipe, Container = cooked dish.
Containers run in separate environments, so different apps can use different versions of software on the same machine without clashing.
When you write -p 8080:80, traffic coming to your machine on port 8080 is sent into the container on port 80.
Virtual Machine
- Full guest OS
- Heavier and slower
- More memory usage
Docker Container
- App plus dependencies
- Lighter and faster
- Shares host OS kernel
docker --version
docker pull nginx
docker run -d -p 8080:80 nginx
docker ps
docker ps -a
docker stop <container_id>
docker rm <container_id>
docker images
Next page: Lesson 2 covers images, containers, and Dockerfile in more depth.