Task
What are the three essential elements of Docker, and how does each contribute to making an app portable and reproducible?
Feedback
- Images
- Immutable “blueprints” that contain the application code, runtime, libraries, and dependencies.
- Ensure consistency: the same image runs the same way across any system.
- Analogy: like a recipe that anyone can use to bake the same cake, no matter where the kitchen is.
- Containers
- Running instances of images that are isolated but lightweight.
- Provide the execution environment with controlled resources (CPU, memory, filesystem).
- Analogy: like baking a cake from the recipe—each cake (container) is independent but based on the same recipe (image).
- Configuration (env vars, volumes, ports)
- Env Vars: settings that change how the app runs without altering the image (e.g., API keys, language, location).
- Volumes: persistent storage that outlives the container (e.g., saving user data).
- Ports: define how the container talks to the outside world (e.g., port 80 for web traffic).
- Analogy: env vars are like dials on a machine, volumes are like external hard drives, and ports are like doors or windows letting traffic in and out.