Home / Reference

Running robots in Docker

A robot can run as a plain process on the agent (the default) or in its own container. A container isolates the robot's dependencies and secrets, limits memory and CPU, and gives the same result on a laptop, an on-premises Linux or Windows server, or a cloud VM (GCP, Azure, AWS): the only thing the machine needs is a Docker Engine.

Choose how a robot runs

The robot's runtime decides it. In the console, the wizard's second step asks "How it runs"; on the CLI:

obskitpy robot create --key ETL_VENDAS --entrypoint main.py --repo-url https://github.com/acme/etl --runtime docker
obskitpy robot create --key REPORT --entrypoint main.py --runtime docker:ghcr.io/acme/report:1.4   # a prebuilt image
runtime What the agent does
empty runs python main.py as a process (needs the dependencies on the agent)
docker builds an image from the code and runs the entrypoint in it
docker:IMAGE pulls the image if it is missing and runs the entrypoint in it

What happens in a docker run

  1. The agent fetches the source: the commit of the deployed release (the branch head before the first deployment), or the agent's --source-dir for robots without a repository.
  2. It builds an image once per commit. If the project has a Dockerfile, it is used. Otherwise one is generated: python:3.12-slim, pip install -r requirements.txt (or pip install . for a pyproject.toml), the code in /app, a /data folder.
  3. It runs the container with --rm --init, only the robot's own environment (never the agent's variables), the credentials resolved by name from the agent's environment and passed through a private file (they never appear in the process list), memory and CPU limits, no-new-privileges, the agent's user (not root), and the robot's data folder mounted at /data.
  4. Logs stream to the portal as usual. A cancel or a timeout stops the container.

The next run of the same release reuses the image (a few seconds instead of a build).

Output that survives the container

Every robot gets a folder on the agent, <data-dir>/<robot>/<env> (default ~/.obskitpy/data), mounted as /data and exposed as OBSKITPY_DATA_DIR. Write your outputs there (databases, files). Process robots get the same variable pointing at the same folder.

Docker on macOS and Windows

Docker runs in a VM that only shares some folders (your home folder, normally). Keep --data-dir inside one of them.

Agent options

obskitpy agent run --env dev hmg \
  --data-dir /srv/obskitpy/data \
  --base-image python:3.12-slim \
  --docker-memory 2g --docker-cpus 2 \
  --docker-network obskitpy-mystack_default \
  --container-otlp-endpoint http://otel-collector:4317

Where it runs

Running the agent itself in a container needs access to the host's Docker (/var/run/docker.sock), which is equivalent to root on that host: do it only on machines dedicated to robots.

Limits today

✎ Edit this page on GitHub