Manuel Gomes
11/17/2025, 2:39 PMMarvin
11/17/2025, 2:39 PMManuel Gomes
11/17/2025, 2:42 PMMarvin
11/17/2025, 2:53 PMregistry_credentials.
Here’s a complete example using the Python SDK:
from prefect.client.orchestration import get_client
from prefect.client.schemas.actions import WorkPoolUpdate
from prefect_docker.credentials import DockerRegistryCredentials
# 1) Create/save the Docker registry credentials as a block
creds = DockerRegistryCredentials(
registry_url="<http://ghcr.io|ghcr.io>", # e.g. <http://ghcr.io|ghcr.io>, <http://index.docker.io|index.docker.io>, <http://your-registry.example.com|your-registry.example.com>
username="my-user",
password="my-password",
)
block_document_id = creds.save("my-ghcr-creds", overwrite=True) # returns the block doc id
# 2) Attach the block to your work pool's default job variables
pool_name = "my-docker-pool"
async def set_pool_creds():
async with get_client() as client:
pool = await client.read_work_pool(pool_name)
variables = dict(pool.variables or {})
variables["registry_credentials"] = {"block_document_id": str(block_document_id)}
await client.update_work_pool(
work_pool_name=pool_name,
work_pool=WorkPoolUpdate(variables=variables),
)
import asyncio
asyncio.run(set_pool_creds())
Notes:
- The key you need to set is registry_credentials. You can confirm this by inspecting the default Docker job template; it includes registry_credentials in the job configuration and variable schema.
- You can also inline credentials (not recommended for secrets). If you must, set:
variables["registry_credentials"] = {
"registry_url": "<http://ghcr.io|ghcr.io>",
"username": "my-user",
"password": "my-password",
}
Using a block is preferred so your password is stored as a secret.
- After updating pool defaults, new runs read them automatically; if you have a long-running worker, a quick restart ensures it picks up changes.
Relevant references:
- Default Docker work pool template (shows the registry_credentials variable): run prefect work-pool get-default-base-job-template --type docker
- Docker registry credentials block class docs: DockerRegistryCredentials
- Related discussion about seeing the credentials section in the UI for Docker pools (confirms the feature): GitHub issue #18490
If you share your pool name and registry (Docker Hub, GHCR, ECR, etc.), I can tailor the snippet to your setup.Manuel Gomes
11/17/2025, 3:42 PMMartin Patz
11/18/2025, 9:16 PM