Docker

Prerequisites

To run Docker agents locally, you must have the Docker engine installed on your machine. More information can be found here.

Configuring your Docker agent

Docker agents are configured using a YML file:

# docker_agent.yml

agent:
  type: docker
  image: <base image>
  server_url:  # URL to the docker server
  requirements:  # path to requirements.txt, relative to this file
  env:
    <env var 1>: 'env var 1 value'

The YML file has a single top-level key, agent. This key contains all the configurations needed for your agent. Specifically:

  • type: this will always be docker for Docker agents

  • image: the base image for your custom, Prism Docker image. If this is not specified, then Prism defaults to python:3.10.8-slim-bullseye.

  • server_url: URL to the Docker server. If this is not specified, then Prism defaults to unix://var/run/docker.sock

  • requirements: path to the requirements.txt file. This path must be relative to the path of the agent YML file.

  • env: {key,value} pairs representing environment variables to add to your Docker image

Example agent

For the remainder of this guide, let's assume that we have the following project.

And, let's assume that we defined our docker_agent.yml as follows:

Note the way we specified the requirements key. We can do this because docker_agent.yml and requirements.txt are in the same directory.

Creating your Docker agent

You can build your Docker agent using the command: prism agent apply -f <path to agent YML>:

This commands builds a custom Docker image. In the example above, this image is called etl-project-docker-agent:1.0.

Multiple prism agent apply calls will increment the tag associated with the custom Docker image. For example, if we were to call prism agent apply again, then Prism would re-build the Docker image and name it etl-project-docker-agent:1.1.

Running your Docker agent

There are two commands you can use to run your Docker agent.

prism agent run

The prism agent run command runs a transient container with your Docker image. This container is automatically removed on daemon side when the container’s process exits.

prism agent build

The prism agent build command re-builds your Docker image and then runs a transient container with your newly built image. As with prism agent run, this container is automatically removed on daemon side when the container’s process exits.

Notice that this command re-built the image: now, the image tag is 1.1, not 1.0.

More information on these commands can be found in the CLI section.

Last updated