# Docker Tasks
Collection of tasks for orchestrating Docker images and containers.
Note: If running these tasks from inside of a docker container itself there are some extra requirements needed for that to work. The container needs to be able to talk to a Docker server. There are a few ways to accomplish this:
- Use a base image that has Docker installed and running (e.g. https://hub.docker.com/_/docker)
- Installing the Docker CLI in the base image
- Talking to an outside (but accessible) Docker API and providing it to the tasks'
docker_server_url
parameter
It may also help to run your container (which will run the Prefect Docker tasks) with extra privileges. (e.g. --privileged=true) and then installing Docker in the container.
# BuildImage
class
prefect.tasks.docker.images.BuildImage
(path=None, tag=None, nocache=False, rm=True, forcerm=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, stream_logs=False, **kwargs)[source]Task for building a Docker image. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
path (str, optional)
: The path to the directory containing the Dockerfiletag (str, optional)
: The tag to give the final imagenocache (bool, optional)
: Don't use cache when set toTrue
rm (bool, optional)
: Remove intermediate containers; defaults toTrue
forcerm (bool, optional)
: Always remove intermediate containers, even after unsuccessful builds; defaults toFalse
docker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodbuild
). See https://docker-py.readthedocs.io/en/stable/api.html for more detailsstream_logs (bool, optional)
: Adds debug logs with build image status info from Docker**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.BuildImage.run (path=None, tag=None, nocache=False, rm=True, forcerm=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, stream_logs=False)[source] |
Task run method.
|
# ListImages
class
prefect.tasks.docker.images.ListImages
(repository_name=None, all_layers=False, filters=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for listing Docker images. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
repository_name (str, optional)
: Only show images belonging to this repository; if not provided then it will list all images from the local Docker serverall_layers (bool, optional)
: Show intermediate image layersfilters (dict, optional)
: Filter the results. See https://docker-py.readthedocs.io/en/stable/images.html for more detailsdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodimages
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.ListImages.run (repository_name=None, all_layers=False, filters=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# PullImage
class
prefect.tasks.docker.images.PullImage
(repository=None, tag=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, stream_logs=False, **kwargs)[source]Task for pulling a Docker image. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
repository (str, optional)
: The repository to pull the image fromtag (str, optional)
: The tag of the image to pull; if not specified then thelatest
tag will be pulleddocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodpull
). See https://docker-py.readthedocs.io/en/stable/api.html for more detailsstream_logs (bool, optional)
: Adds debug logs with pull status info from Docker**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.PullImage.run (repository=None, tag=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, stream_logs=False)[source] |
Task run method.
|
# PushImage
class
prefect.tasks.docker.images.PushImage
(repository=None, tag=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for pushing a Docker image. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
repository (str, optional)
: The repository to push the image totag (str, optional)
: The tag for the image to push; if not specified then thelatest
tag will be pusheddocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodpush
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.PushImage.run (repository=None, tag=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# RemoveImage
class
prefect.tasks.docker.images.RemoveImage
(image=None, force=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for removing a Docker image. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
image (str, optional)
: The image to removeforce (bool, optional)
: Force removal of the imagedocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodremove_image
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.RemoveImage.run (image=None, force=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# TagImage
class
prefect.tasks.docker.images.TagImage
(image=None, repository=None, tag=None, force=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for tagging a Docker image. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
image (str, optional)
: The image to tagrepository (str, optional)
: The repository to set for the tagtag (str, optional)
: The tag name for the imageforce (bool, optional)
: Force tagging of the imagedocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodtag
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.images.TagImage.run (image=None, repository=None, tag=None, force=False, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# CreateContainer
class
prefect.tasks.docker.containers.CreateContainer
(image_name=None, container_name=None, command=None, detach=False, entrypoint=None, environment=None, volumes=None, docker_server_url="unix:///var/run/docker.sock", host_config=None, extra_docker_kwargs=None, **kwargs)[source]Task for creating a Docker container and optionally running a command. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
image_name (str, optional)
: Name of the image to runcontainer_name (str, optional)
: A name for the containercommand (Union[list, str], optional)
: A single command or a list of commands to rundetach (bool, optional)
: Run container in the backgroundentrypoint (Union[str, list], optional)
: The entrypoint for the containerenvironment (Union[dict, list], optional)
: Environment variables to set inside the container, as a dictionary or a list of strings in the format ["SOMEVARIABLE=xxx"]volumes (Union[str, list], optional)
: List of paths inside the container to use as volumesdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedhost_config (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodcreate_host_config
). See https://docker-py.readthedocs.io/en/stable/api.html for more detailsextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodcreate_container
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.CreateContainer.run (image_name=None, container_name=None, command=None, detach=False, entrypoint=None, environment=None, volumes=None, docker_server_url="unix:///var/run/docker.sock", host_config=None, extra_docker_kwargs=None)[source] |
Task run method.
|
# GetContainerLogs
class
prefect.tasks.docker.containers.GetContainerLogs
(container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for getting the logs of a Docker container. Note: This does not stream logs. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
container_id (str, optional)
: The id of a container to retrieve logs fromdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodlogs
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.GetContainerLogs.run (container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# ListContainers
class
prefect.tasks.docker.containers.ListContainers
(all_containers=False, filters=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for listing Docker containers. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
all_containers (bool, optional)
: Show all containers. Only running containers are shown by defaultfilters (dict, optional)
: Filter the results. See https://docker-py.readthedocs.io/en/stable/containers.html for more detailsdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodcontainers
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.ListContainers.run (all_containers=False, filters=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# StartContainer
class
prefect.tasks.docker.containers.StartContainer
(container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for starting a Docker container that runs the (optional) command it was created with. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
container_id (str, optional)
: The id of a container to startdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodstart
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.StartContainer.run (container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# StopContainer
class
prefect.tasks.docker.containers.StopContainer
(container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for stopping a Docker container. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
container_id (str, optional)
: The id of a container to stopdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodstop
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.StopContainer.run (container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# RemoveContainer
class
prefect.tasks.docker.containers.RemoveContainer
(container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None, **kwargs)[source]Task for removing a Docker container. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
container_id (str, optional)
: The id of a container to removedocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedextra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodremove_container
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.RemoveContainer.run (container_id=None, docker_server_url="unix:///var/run/docker.sock", extra_docker_kwargs=None)[source] |
Task run method.
|
# WaitOnContainer
class
prefect.tasks.docker.containers.WaitOnContainer
(container_id=None, docker_server_url="unix:///var/run/docker.sock", raise_on_exit_code=True, extra_docker_kwargs=None, **kwargs)[source]Task for waiting on an already started Docker container. Note that all initialization arguments can optionally be provided or overwritten at runtime.
Args:
container_id (str, optional)
: The id of a container to startdocker_server_url (str, optional)
: URL for the Docker server. Defaults tounix:///var/run/docker.sock
however other hosts such astcp://0.0.0.0:2375
can be providedraise_on_exit_code (bool, optional)
: whether to raise aFAIL
signal for a nonzero exit code; defaults toTrue
extra_docker_kwargs (dict, optional)
: Extra keyword arguments to pass through to the Docker call (cf. methodwait
). See https://docker-py.readthedocs.io/en/stable/api.html for more details**kwargs (dict, optional)
: Additional keyword arguments to pass to the Task constructor
methods: |
---|
prefect.tasks.docker.containers.WaitOnContainer.run (container_id=None, docker_server_url="unix:///var/run/docker.sock", raise_on_exit_code=True, extra_docker_kwargs=None)[source] |
Task run method.
|
This documentation was auto-generated from commit n/a
on July 1, 2021 at 18:35 UTC