Learn how to execute deployments in isolated Docker containers
my-docker-pool
listed in the output.
Next, check that you can see this work pool in your Prefect UI.
Navigate to the Work Pools tab and verify that you see my-docker-pool
listed.
When you click into my-docker-pool
, you should see a red status icon signifying that this work pool is not ready.
To make the work pool ready, you’ll need to start a worker.
We’ll show how to do this next.
prefect
installed.
Run the following command in this new terminal to start the worker:
Ready
status indicator.
my-docker-pool
does not already exist, the below command will create it for you automatically with the default settings for that work pool type, in this case docker
..deploy
method on a flow:
Deployments
page in the UI.
By default, .deploy
builds a Docker image with your flow code baked into it and pushes the image to the
Docker Hub registry implied by the image
argument to .deploy
.
image
argument.
push=False
in the .deploy
method:
build=False
in the .deploy
method:
requirements.txt
file.
DockerImage
:
DockerImage
object enables image customization.
For example, you can install a private Python package from GCP’s artifact registry like this:
DockerImage
class:
DockerImage
class.
PREFECT_DEFAULT_DOCKER_BUILD_NAMESPACE
setting to append a default Docker namespace to all images
you build with .deploy
. This is helpful if you use a private registry to store your images.To set a default Docker namespace for your current profile run:<docker-registry-url>/<organization-or-username>/my_image:my_image_tag
when PREFECT_DEFAULT_DOCKER_BUILD_NAMESPACE
is set.image
argument for .deploy
, you must specify where to pull the flow code from at runtime
with the from_source
method.
Here’s how to pull your flow code from a GitHub repository:
entrypoint
is the path to the file the flow is located in and the function name, separated by a colon.
See the Store flow code guide for more flow code storage options.
.deploy
parameters
argument in the .deploy
method. Just pass in a dictionary of
key-value pairs.
job_variables
parameter allows you to fine-tune the infrastructure settings for a deployment.
The values passed in override default values in the specified work pool’s
base job template.
You can override environment variables, such as image_pull_policy
and image
, for a specific deployment with the job_variables
argument.
job_variables
parameter:
requirements.txt
copied into it.
See Override work pool job variables for more information about how to customize these variables.
deploy
.deploy
.
You can manage these deployments independently of one another to deploy the same flow with different configurations
in the same codebase.
To create multiple deployments at once, use the deploy
function, which is analogous to the serve
function:
from_source
method.
Here’s an example of deploying two flows, one defined locally and one defined in a remote repository:
deploy
function.
This is useful if using a monorepo approach to your workflows.