Glyn Finck
11/19/2025, 10:40 PMbase_job_template must contain both a job_configuration key and a variables key when trying to pass the DockerWorkerConfiguration to this.Marvin
11/19/2025, 10:40 PMMarvin
11/19/2025, 10:47 PMbase_job_template must be a JSON-serializable dict with two top-level keys: job_configuration and variables. Passing a DockerWorkerJobConfiguration (or a dict of its fields) will not work—the API expects the templated structure, not the concrete config.
In Prefect 3.x, the easiest and safest way is to start from the worker’s default template and pass that dict to the work pool create call.
Quick working example (Python, async):
import asyncio
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import WorkPoolCreate
from prefect_docker.worker import DockerWorker
async def main():
# Get a valid template for Docker workers
base_job_template = DockerWorker.get_default_base_job_template()
# Optional: tweak defaults or add fields
# For example, set a default image or toggle auto_remove:
base_job_template["variables"]["properties"]["image"]["default"] = "my-registry/my-image:latest"
base_job_template["variables"]["properties"]["auto_remove"] = {
"type": "boolean",
"default": True,
"description": "Remove containers after the run"
}
base_job_template["job_configuration"]["auto_remove"] = "{{ auto_remove }}"
async with get_client() as client:
await client.create_work_pool(
WorkPoolCreate(
name="my-docker-pool",
type="docker", # important
base_job_template=base_job_template,
description="Docker pool created from Python",
is_paused=False,
),
overwrite=True, # optional: update if it exists
)
asyncio.run(main())
What not to do (this triggers your error):
# ❌ This will fail
from prefect_docker.worker import DockerWorkerJobConfiguration
bad_template = DockerWorkerJobConfiguration(image="...").model_dump()
# Missing the required 'job_configuration' and 'variables' structure
Notes
- The template uses Jinja-like placeholders in job_configuration (e.g., "{{ image }}"), and a JSON Schema for variables that defines what can be set by deployments or defaults.
- There is no DockerWorkerConfiguration class; the Prefect integration exposes DockerWorker and DockerWorkerJobConfiguration. For creating pools, use DockerWorker.get_default_base_job_template().
Useful links
- Work Pools concepts: Work Pools (docs)
- Manage work pools: Manage Work Pools (docs)
- Docker deployment how-to: Deploy in Docker (docs)
- API reference (schemas actions incl. WorkPoolCreate): Python API: schemas.actions
- Docker worker source (for reference): prefect_docker/worker.py
If you can share the snippet you used to build the template, I can point out exactly what to change. Also, which Prefect version are you on? I’ve assumed 3.x above.