Intro to Docker
This tutorial introduces containers via teaching how to use docker. This part is not designed for HPC but understanding the idea of a container is important.
If you understand docker then skip to here.
Docker is a tool that packages applications and their dependencies into containers, ensuring they run the same way on any system. It's useful because it:
Ensures Consistency across different environments (e.g., development, testing, production).
Isolates Applications, preventing conflicts and improving security.
Makes Deployment Easy by packaging everything needed to run an app in one container.
Increases Efficiency since containers are lightweight and use less resources compared to traditional virtual machines.
In short, Docker simplifies running and deploying applications by making them portable and consistent.
Download sample code
The dockerfile tells docker how to setup the containner:
Build and Run the Docker Container
Build the Docker Image:
In a local terminal that has the directory with ml_app.py open: (This may need logging into docker with docker login and using a dockerhub account)
Run the Container Locally:
This will print the model's accuracy and the prediction for the sample flower measurements in your terminal.
Push to Docker Hub and Deploy on a VM - skip if doing workshop
Log In to Docker Hub: needs https://hub.docker.com/account
Tag and Push the Image: (change username to your docker hub account username)
On the VM, Pull and Run the Image:
You can follow here to connect to a jetstream 2 vm
Pull the Docker Image:
This command downloads the Docker image
dukeieee/ml-app
from Docker Hub to your local system or VM. The image contains the Python ML app and its required dependencies.Run the Docker Container:
This command starts a container using the downloaded image. The app will train a machine learning model on the iris dataset and print the model's accuracy and predictions directly to your terminal.
This approach ensures that the app runs with all necessary dependencies, regardless of the environment, providing a consistent and reproducible setup.
Last updated