Docker image

Run an existing Docker image as a task on Airplane.
This guide will get you up and running with an example Docker image task.
The Docker image task type is the most powerful type, as you can build and run any custom image on Airplane. This is useful if you're already building an image, or if you have a custom build process for your Docker images, and you want to use that image for your Airplane task.
If you'd like a custom Docker image but want Airplane to manage the build step, we recommend using Shell tasks, which allows specifying your own Dockerfile.

Getting started

We'll use the Airplane CLI airplane to demonstrate how to get started with a Docker image task.
If you haven't yet, first install the Airplane CLI by following the instructions at Installing the CLI.

Create your task

Once you've installed and logged in to the CLI, navigate to the folder where you want to create your task and run:
bash
Copied
1
airplane tasks init
You'll be prompted for some information:
  • Enter a name for the task.
  • Select Docker as the kind.
  • Enter a name for the the definition file. The definition file contains task metadata as well as the defition of the Docker image (e.g. delete_user_by_email.task.yaml).

Parameters

Parameters allow you to prompt users for input before triggering your task. See Parameters for more information.
Open up the definition file (the file with extension .task.yaml) to add parameters to the task.
yaml
Copied
1
parameters:
2
- name: User ID
3
slug: user_id
4
type: shorttext
5
description: The ID of the user
Parameters can be passed into the command as {{params.slug}}:
yaml
Copied
1
docker:
2
command: /bin/my_command --id {{params.user_id}}
If you have control over the command arguments being run, we recommend using {{JSON.stringify(params)}} to easily serialize parameters and pass them into your image.
yaml
Copied
1
docker:
2
command: /bin/my_command {{JSON.stringify(params)}}
javascript
Copied
1
// my_command receives a JSON string:
2
{"user_id": "John"}

Build your image

Specify the image to use and the command to run:
Example:
yaml
Copied
1
docker:
2
image: ubuntu:22.04
3
command: echo hello world
The image will be executed as the user specificed in the Docker image.
If necessary, you can also set an entrypoint. If left unset, Airplane will use the default entrypoint of the image (if any).

Deploy to Airplane

Finally, run deploy to push your task to Airplane:
bash
Copied
1
airplane deploy your_task.task.yaml
Once deployed, go to the Tasks page to run and share your task!