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:
bashCopied1airplane 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.yamlCopied1parameters:2- name: User ID3slug: user_id4type: shorttext5description: The ID of the user
Parameters can be passed into the
command
as {{params.slug}}
:yamlCopied1docker:2command: /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.yamlCopied1docker:2command: /bin/my_command {{JSON.stringify(params)}}
javascriptCopied1// my_command receives a JSON string:2{"user_id": "John"}
Build your image
Specify the image to use and the command to run:
Example:
yamlCopied1docker:2image: ubuntu:22.043command: echo hello world
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:
bashCopied1airplane deploy your_task.task.yaml
Once deployed, go to the Tasks page to run and share your task!