Q&A 10 How do you pull and run your model API image from Docker Hub?

10.1 Explanation

After pushing your trained model image to Docker Hub, you can reuse it on any machine or server with Docker installed. This step is key in model deployment because it enables reproducibility, portability, and team collaborationβ€”you don’t have to re-train or re-build the image every time.

10.2 Bash Code

10.2.1 Pull the image from Docker Hub

xample using tnbuza username

docker pull tmbuza/model-api

10.3 Run the Docker container

docker run -d -p 8000:8000 tmbuza/model-api

Explanation:

  • -d = run in detached mode
  • -p 8000:8000 = map internal container port 8000 to local machine port 8000

10.4 Test the running API

Visit the following URL in your browser:

http://127.0.0.1:8000/docs

You should see the interactive FastAPI Swagger UI to test predictions directly.

βœ… Takeaway: Pulling and running your model API from Docker Hub turns it into a reusable and portable microservice β€” ideal for deployment on servers, sharing with teams, or testing in production-like environments.