Implements Docker operator
DockerOperator(image, api_version=None, command=None, container_name=None, cpus=1.0, docker_url='unix://var/run/docker.sock', environment=None, force_pull=False, mem_limit=None, host_tmp_dir=None, network_mode=None, tls_ca_cert=None, tls_client_cert=None, tls_client_key=None, tls_hostname=None, tls_ssl_version=None, tmp_dir='/tmp/airflow', user=None, volumes=None, working_dir=None, xcom_push=False, xcom_all=False, docker_conn_id=None, dns=None, dns_search=None, auto_remove=False, shm_size=None, tty=False, *args, **kwargs)¶
Execute a command inside a docker container.
A temporary directory is created on the host and mounted into a container to allow storing files that together exceed the default disk size of 10GB in a container. The path to the mounted directory can be accessed via the environment variable
If a login to a private registry is required prior to pulling the image, a Docker connection needs to be configured in Airflow and the connection ID be provided with the parameter
image (str) – Docker image from which to create the container. If image tag is omitted, “latest” will be used.
api_version (str) – Remote API version. Set to
autoto automatically detect the server’s version.
auto_remove (bool) – Auto-removal of the container on daemon side when the container’s process exits. The default is False.
cpus (float) – Number of CPUs to assign to the container. This value gets multiplied with 1024. See https://docs.docker.com/engine/reference/run/#cpu-share-constraint
docker_url (str) – URL of the host running the docker daemon. Default is unix://var/run/docker.sock
environment (dict) – Environment variables to set in the container. (templated)
force_pull (bool) – Pull the docker image on every run. Default is False.
host_tmp_dir (str) – Specify the location of the temporary directory on the host which will be mapped to tmp_dir. If not provided defaults to using the standard system temp directory.
network_mode (str) – Network mode for the container.
tls_ca_cert (str) – Path to a PEM-encoded certificate authority to secure the docker connection.
tls_client_cert (str) – Path to the PEM-encoded certificate used to authenticate docker client.
tls_client_key (str) – Path to the PEM-encoded key used to authenticate docker client.
tls_ssl_version (str) – Version of SSL to use when communicating with docker daemon.
tmp_dir (str) – Mount point inside the container to a temporary directory created on the host by the operator. The path is also made available via the environment variable
AIRFLOW_TMP_DIRinside the container.
volumes (list) – List of volumes to mount into the container, e.g.
working_dir (str) – Working directory to set on the container (equivalent to the -w switch the docker client)
xcom_push (bool) – Does the stdout will be pushed to the next step using XCom. The default is False.
xcom_all (bool) – Push all the stdout or just the last line. The default is False (last line).
docker_conn_id (str) – ID of the Airflow connection to use
shm_size (int) – Size of
/dev/shmin bytes. The size must be greater than 0. If omitted uses system default.
tty (bool) – Allocate pseudo-TTY to the container This needs to be set see logs of the Docker container.
template_fields= ['command', 'environment', 'container_name']¶
template_ext= ['.sh', '.bash']¶
Run a Docker container with the provided image
Retrieve command(s). if command string starts with [, it returns the command list)
the command (or commands)
- Return type
str | List[str]