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:

yaml
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.

docker_runner

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.

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

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?