Georg Raiser
08/22/2025, 8:30 AMprefect.deploy() I can specify the docker image to be used for that deployment by passing the image kwarg. However, if I try to use prefect.deployments.run_deployment() I don't have that argument - what is the correct way to specify this?Marvin
08/22/2025, 8:30 AMMarvin
08/22/2025, 8:33 AMimage kwarg is a deployment-time setting. When you trigger a run with prefect.deployments.run_deployment, you can’t pass image directly — instead, you override the deployment’s job template per run using the job_variables argument.
In practice, set the image via job_variables (the exact keys depend on your work pool’s base job template; for Docker/Kubernetes it’s image):
- Docker work pool example:
from prefect.deployments import run_deployment
flow_run = run_deployment(
"my-flow/my-deployment",
job_variables={"image": "myrepo/myimage:tag"}
)
- Kubernetes work pool example:
from prefect.deployments import run_deployment
flow_run = run_deployment(
"my-flow/my-deployment",
job_variables={
"image": "myrepo/myimage:tag",
# optional extras if your template exposes them:
"image_pull_policy": "Always"
}
)
Notes:
- Make sure your work pool’s base job template exposes an image field (the Docker and Kubernetes templates do).
- If you’re setting the image at deploy-time instead, continue using deploy(..., image="...").
Docs for more detail:
- Customize job variables
- Docker work pool guide
- Kubernetes work pool guide
If you share which work pool you’re using (Docker or Kubernetes), I can confirm the exact keys your template supports.