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
- The agent fetches the source: the commit of the deployed release (the branch head before the first deployment), or the agent's
--source-dirfor robots without a repository. - 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(orpip install .for apyproject.toml), the code in/app, a/datafolder. - 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. - 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
--docker-networkattaches the containers to the obskitpy stack's network, so they reach the Collector by name. Without it, alocalhostendpoint is mapped tohost.docker.internal.- A robot can override the limits with the variables
OBSKITPY_DOCKER_MEMORYandOBSKITPY_DOCKER_CPUS(they are not passed to the container). - The agent registers the label
docker=truewhen it can reach a Docker daemon. A docker robot on an agent without Docker fails with a clear message.
Where it runs
- On-premises Linux: install Docker Engine and run the agent as a service (systemd) under a user that may use Docker.
- Windows: Docker Desktop with Linux containers; the agent runs from PowerShell or as a service. Not verified yet.
- GCP, Azure, AWS: a VM (Compute Engine, an Azure VM, EC2) with Docker and the agent, with only outbound access to the portal. Not verified yet.
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
- The robot's own dependencies are installed at build time from
requirements.txtorpyproject.toml; there is no private-registry login or build secrets yet. - Python robots only (the generated Dockerfile). Other languages need their own
Dockerfile. - An agent does not yet pick runs by label, so mix agents with and without Docker carefully.