Docker Task Runner
Available on: >= 0.16.0
Run tasks as Docker containers.
Here is an example using the Docker task runner executing the commands in a Docker container:
id: docker_script_runner
namespace: company.team
tasks:
- id: shell
type: io.kestra.plugin.scripts.shell.Commands
containerImage: centos
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
cpu:
cpus: 1
commands:
- echo "Hello World!"
Once you specify the taskRunner
type, you get the autocompletion and validation for the runner-specific properties. In the example above, the task allocates 1 CPU to the container.
The only property required by the taskRunner
is the containerImage
property that needs to be set on the script task. The image can be from a public or private registry. Additionally, using the Docker task runner you can configure memory allocation, volumes, environment variables, and more. For a full list of properties available in the Docker task runner, check the Docker plugin documentation or explore the same in the built-in Code Editor in the Kestra UI.
The Docker task runner executes the script task as a container in a Docker-compatible engine. This means that you can also use it to run scripts within a Kubernetes cluster with Docker-In-Docker (dind) or in a local Docker engine.
Also, keep in mind that if a Kestra Worker executing the script is terminated (e.g. due to a crash), the container will still run until completion. When running Kestra itself in a container with Docker-In-Docker (dind), both the worker and container will be restarted.
Insecure Registry
The Docker task runner supports insecure registries. Prior to using this feature, ensure the insecure registry is configured on the host machine that your Kestra server is running on.
For example, if you have the insecure registry 10.10.1.5:5000, please add the following configuration to /etc/docker/daemon.json
and then restart your Docker daemon.
{
"insecure-registries" : ["10.10.1.5.:5000"]
}
This can then be used in a flow with the following YAML
id: docker_example
namespace: demo
tasks:
- id: my_command
type: io.kestra.plugin.scripts.shell.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
config: |
{
"insecure-registries" : ["10.10.1.5:5000"]
}
containerImage: 10.10.1.5:5000/my-image
commands:
- my-command
Was this page helpful?