Docker for AI/ML
Outline
Overview
Topics
Why containerization for ML?
What you’ll build
Prerequisites
Ready to start?
Docker concepts
Core terminology
Image
Container
Host
Dockerfile
Registry
Tag
Volume
Port mapping
Common commands
Building images
Running containers
Managing containers
Managing images
Cleanup
Why Docker for ML?
Reproducibility
Portability
Isolation
Modularity
Next steps
Dockerfile guide
Essential instructions
FROM
WORKDIR
COPY
RUN
CMD
EXPOSE
ENV
USER
Complete example
Best practices
Layer caching
Minimize layers
Use .dockerignore
Keep images small
Specific tags
Security
Common patterns
ML training container
Model serving container
Jupyter notebook container
Debugging tips
Build with verbose output
Inspect intermediate layers
Check build context size
Next steps
Lab 1: Data cleaner container
Learning objectives
What’s included
The scenario
Step-by-step instructions
1. Examine the Dockerfile
2. Build the Docker image
3. Verify the image
4. Prepare data directory
5. Run the container
6. Examine the output
Key concepts
Experiment further
What’s next?
Lab 2: Streamlit dashboard container
Learning objectives
What’s included
The scenario
Step-by-step instructions
1. Examine the Dockerfile
2. Build the image
3. Run the container with port mapping
4. Access the dashboard
5. Explore the dashboard
6. Load your own data (optional)
7. Run on a different port
8. Run in detached mode
Key concepts
Use cases for ML/data science
Experiment further
What’s next?
Lab 3: ML development container
Learning objectives
What’s included
The scenario
Part 1: Build and test your development image
1. Examine the Dockerfile
2. Build the image
3. Test the environment
4. Try interactive development
Part 2: Customize your environment
5. Add your preferred packages
6. Rebuild with customizations
Part 3: Publish to Docker Hub
7. Tag for Docker Hub
8. Login to Docker Hub
9. Push to Docker Hub
10. Verify on Docker Hub
Part 4: Use your image as a VS Code dev container
11. Examine the dev container configuration
12. Open in VS Code dev container (optional)
Part 5: Verify portability with GitHub Codespaces
13. Create a test repository
14. Launch GitHub Codespace
15. Test in Codespace
Key concepts
Real-world ML applications
Alternative registries
Experiment further
Troubleshooting
What you’ve accomplished
Next steps
Congratulations!
Docker for AI/ML
Index
Index