0
0
Dockerdevops~10 mins

Development vs production Dockerfiles - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - Development vs production Dockerfiles
Start: Write Dockerfile
Choose environment
Development
Add dev tools
Build dev image
Run with debug
Test & Debug
Shows the flow of creating Dockerfiles for development and production environments, highlighting different steps and goals.
Execution Sample
Docker
FROM python:3.12-slim
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
A simple Dockerfile that copies app code, installs dependencies, and runs the app.
Process Table
StepDockerfile TypeActionEffectResulting Image Size
1DevelopmentUse full python:3.12 imageIncludes dev tools and debuggingLarge (~1GB)
2DevelopmentCopy all source codeFull app code availableNo size change
3DevelopmentInstall all dependenciesReady to run with debugMedium increase
4DevelopmentSet CMD to run app with debugContainer runs with debug modeNo size change
5ProductionUse python:3.12-slim imageSmaller base imageSmall (~200MB)
6ProductionCopy only necessary filesExclude tests and docsSmaller size
7ProductionInstall only runtime dependenciesNo dev tools installedSmaller increase
8ProductionSet CMD to run app normallyRuns app without debugNo size change
9ExitBuild completeImages ready for respective environments-
💡 Both Dockerfiles built; development image is larger with debug tools, production image is smaller and optimized.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 5After Step 7Final
Image SizeBase sizeBase + source codeBase + source + depsSlim base sizeSlim base + runtime depsFinal image size
Debug ToolsNoneIncluded in dev imageIncludedNoneNoneOnly in dev image
Source CodeNoneFull copyFull copyPartial copyPartial copyFull in dev, partial in prod
Key Moments - 3 Insights
Why is the development image much larger than the production image?
Because the development Dockerfile includes full Python with dev tools and copies all source code, as shown in execution_table rows 1-4, increasing size.
Why do we copy fewer files in the production Dockerfile?
To keep the image small and secure by excluding tests and docs, as shown in execution_table row 6.
Why do we install fewer dependencies in production?
Production installs only runtime dependencies to reduce size and surface area, as shown in execution_table row 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the image size after step 5 in the production Dockerfile?
ALarge (~1GB)
BSmall (~200MB)
CMedium increase
DNo size change
💡 Hint
Check the 'Resulting Image Size' column at step 5 for production Dockerfile.
At which step does the development Dockerfile set the command to run the app with debug?
AStep 4
BStep 3
CStep 2
DStep 6
💡 Hint
Look at the 'Action' column for development Dockerfile steps in the execution table.
If we copied all files in production like in development, how would the image size change?
AIt would stay the same
BIt would become smaller
CIt would become larger
DIt would become zero
💡 Hint
Refer to variable_tracker row 'Image Size' comparing after step 2 and step 6.
Concept Snapshot
Development Dockerfile:
- Uses full image with dev tools
- Copies all source code
- Installs all dependencies
- Runs app with debug

Production Dockerfile:
- Uses slim image
- Copies only needed files
- Installs runtime dependencies only
- Runs app normally

Goal: Dev for debugging, Prod for small, fast, secure image.
Full Transcript
This visual execution compares development and production Dockerfiles. Development Dockerfiles use a full Python image with debugging tools, copy all source code, and install all dependencies, resulting in a larger image. Production Dockerfiles use a slim base image, copy only necessary files, and install only runtime dependencies, making the image smaller and optimized. The execution table shows step-by-step actions and their effects on image size and content. Variable tracking highlights how image size and included tools change. Key moments clarify why development images are larger and why production images exclude extra files and dependencies. The quiz tests understanding of image sizes, commands, and file copying differences. The snapshot summarizes the main differences and goals for each Dockerfile type.