# Docker Agent


# DockerAgent

class

prefect.agent.docker.agent.DockerAgent

(agent_config_id=None, name=None, labels=None, env_vars=None, max_polls=None, agent_address=None, no_cloud_logs=None, base_url=None, no_pull=None, volumes=None, show_flow_logs=False, networks=None, reg_allow_list=None, docker_client_timeout=None)[source]

Agent which deploys flow runs locally as Docker containers. Information on using the Docker Agent can be found at https://docs.prefect.io/orchestration/agents/docker.html

This agent requires Docker v20.10.0+

Environment variables may be set on the agent to be provided to each flow run's container:

prefect agent docker start --env MY_SECRET_KEY=secret --env OTHER_VAR=$OTHER_VAR

The default Docker daemon may be overridden by providing a different base_url:

prefect agent docker start --base-url "tcp://0.0.0.0:2375"

If connecting to a local instance of Prefect Server that does not have the --expose flag set, you must provide a network:

prefect agent docker start --network prefect-server

Args:

  • agent_config_id (str, optional): An optional agent configuration ID that can be used to set configuration based on an agent from a backend API. If set all configuration values will be pulled from backend agent configuration.
  • name (str, optional): An optional name to give this agent. Can also be set through the environment variable PREFECT__CLOUD__AGENT__NAME. Defaults to "agent"
  • labels (List[str], optional): a list of labels, which are arbitrary string identifiers used by Prefect Agents when polling for work
  • env_vars (dict, optional): a dictionary of environment variables and values that will be set on each flow run that this agent submits for execution
  • max_polls (int, optional): maximum number of times the agent will poll Prefect Cloud for flow runs; defaults to infinite
  • agent_address (str, optional): Address to serve internal api at. Currently this is just health checks for use by an orchestration layer. Leave blank for no api server (default).
  • no_cloud_logs (bool, optional): Disable logging to a Prefect backend for this agent and all deployed flow runs
  • base_url (str, optional): URL for a Docker daemon server. Defaults to unix:///var/run/docker.sock however other hosts such as tcp://0.0.0.0:2375 can be provided
  • no_pull (bool, optional): Flag on whether or not to pull flow images. Defaults to False if not provided here or in context.
  • show_flow_logs (bool, optional): a boolean specifying whether the agent should re-route Flow run logs to stdout; defaults to False
  • volumes (List[str], optional): a list of Docker volume mounts to be attached to any and all created containers.
  • networks (List[str], optional): Add containers to existing Docker networks.
  • reg_allow_list (List[str], optional): Limits Docker Agent to only pull images from the listed registries.
  • docker_client_timeout (int, optional): The timeout to use for docker API calls, defaults to 60 seconds.

methods:                                                                                                                                                       

prefect.agent.agent.Agent.start

()[source]

The main entrypoint to the agent process. Sets up the agent then continuously polls for work to submit.

This is the only method that should need to be called externally.



This documentation was auto-generated from commit ffa9a6c
on February 1, 2023 at 18:44 UTC