# Flow with Docker
Previously we used the local agent to execute flow runs directly on the current host. Now we will use a Docker agent to execute flow runs within Docker containers on the current host.
In order to use the Docker features make sure you have Docker currently running on your machine.
# Persisting Your Flow with Docker Storage
import prefect from prefect import task, Flow from prefect.environments.storage import Docker @task def hello_task(): logger = prefect.context.get("logger") logger.info("Hello, Docker!") flow = Flow("hello-docker", tasks=[hello_task]) flow.storage = Docker() flow.register(project_name="Hello, World!")
# Pushing to a Registry
Docker Storage accepts an optional keyword argument
registry_url if this is not specified then the Docker image that is built will only exist on the machine it was built on.
If you do specify a registry URL then the image will be pushed to a container registry upon flow registration.
flow.storage = Docker(registry_url="docker.io/<dockerhub_user>/<dockerhub_repo>")
# Running a Docker Agent
Start the Docker Agent to executing Flow Runs scheduled by the Prefect API:
prefect agent start docker
Runner Token Cloud
This Docker Agent will use the RUNNER token stored in your environment but if you want to manually pass it a token you may do so with
For more information on the Docker Agent visit the documentation.