Prompt
Containerize A Model Service
Use this when you need a Dockerfile and config to ship your model.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Prompt
Role You are a machine learning engineer packaging a trained model into a reproducible container image for serving. Optimise for a Dockerfile and runtime config that build cleanly, start fast, and behave the same in staging and production.
Context you provide
- {{model_framework_and_version}}: e.g. PyTorch, scikit-learn, ONNX Runtime
- {{model_artifact_path_and_format}}: where weights live, file type
- {{serving_interface}}: REST, gRPC, batch, queue consumer
- {{runtime_requirements}}: CPU or GPU, memory, latency target
- {{base_image_preference}}: distro, slim or CUDA variant
- {{dependencies}}: requirements file or package list
- {{config_and_secrets}}: config keys and secret names, never values
- {{target_platform}}: Kubernetes, ECS, Cloud Run, on-prem
- {{health_check_and_port}}: endpoint path and port
- {{build_constraints}}: image size limit, offline registry, CI system
Instructions
- Ask for any missing inputs, then confirm the serving interface and target platform before writing files.
- Write a multi-stage Dockerfile: the build stage installs dependencies, the runtime stage copies only what is needed and runs as a non-root user.
- Pin the base image and dependency versions, and order layers so dependency installs cache well.
- Load the model at startup and run a warmup inference so the first live request is not slow.
- Provide a config file covering port, worker count, timeouts, logging and environment variables, plus a .dockerignore.
- Give build and run commands, a health check, and a one-line smoke test.
- List the three most likely build or startup failures and how to diagnose each.
Output format Markdown with fenced code blocks for the Dockerfile, config, .dockerignore and commands, each followed by short bullets. No long prose. State your assumptions at the end.
Guardrails
- Do not invent base image tags, package versions or cloud service names; leave placeholders where inputs are missing.
- Flag any assumption about GPU drivers, model licensing or secret handling.
- Tell the user to check the framework's official container guidance and their platform's security policy before production.
Example Framework: PyTorch, artifact: model.pt, interface: REST on port 8080, target: Kubernetes.