Skip to main content

Image API Reference

Image API Reference

Customer-hosted cloud features

note

Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.

Image CLI

anyscale image build

Usage

anyscale image build [OPTIONS]

Build an image from a Containerfile.

Options

  • --containerfile/-f: Path to the Containerfile.
  • --name/-n: Name for the image. If the image with the same name already exists, a new version will be built. Otherwise, a new image will be created.
  • --ray-version/-r: The Ray version (X.Y.Z) specified for this image specified by either an image URI or a containerfile. If you don't specify a Ray version, Anyscale defaults to the latest Ray version available at the time of the Anyscale CLI/SDK release.

Examples

$ anyscale image build -f my.Dockerfile -n my-image --ray-version 2.21.0
(anyscale +2.8s) Building image. View it in the UI: https://console.anyscale.com/v2/...
(anyscale +1m53.0s) Waiting for image build to complete. Elapsed time: 102 seconds.
(anyscale +1m53.0s) Image build succeeded.
Image built successfully with URI: anyscale/image/my-image:1

$ cat my.Dockerfile
FROM anyscale/ray:2.21.0-py39
RUN pip install --no-cache-dir pandas

anyscale image get

Usage

anyscale image get [OPTIONS]

Get details of an image.

Options

  • --name/-n: Get the details of an image.

The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be used.

Examples

$ anyscale image get -n my-image
uri: anyscale/image/my-image:1
status: SUCCEEDED
ray_version: 2.21.0

anyscale image register

Usage

anyscale image register [OPTIONS]

Register a custom container image with a container image name.

Options

  • --image-uri: The URI of the custom container image to register.
  • --name/-n: Name for the container image. If the name already exists, a new version will be built. Otherwise, a new container image will be created.
  • --ray-version/-r: The Ray version (X.Y.Z) specified for this image specified by either an image URI or a containerfile. If you don't specify a Ray version, Anyscale defaults to the latest Ray version available at the time of the Anyscale CLI/SDK release.
  • --registry-login-secret: Name or identifier of the secret containing credentials to authenticate to the docker registry hosting the image.

Examples

$ anyscale image register --image-uri docker.io/myrepo/image:v2 --name mycoolimage --ray-version 2.30.0
Image registered successfully with URI: anyscale/image/mycoolimage:1

Image SDK

anyscale.image.build

Build an image from a Containerfile.

Returns the URI of the image.

Arguments

  • containerfile (str): The content of the Containerfile.
  • name (str): The name of the image.
  • ray_version (str | None) = None: The version of Ray to use in the image

Returns: str

Examples

import anyscale

containerfile = '''
FROM anyscale/ray:2.21.0-py39
RUN pip install --no-cache-dir pandas
'''

image_uri: str = anyscale.image.build(containerfile, name="mycoolimage")

anyscale.image.get

The name can contain an optional version tag, i.e., 'name:version'.

If no version is provided, the latest one will be returned.

Arguments

  • name (str): Get the details of an image.

The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be used.

Returns: ImageBuild

Examples

import anyscale

image_status = anyscale.image.get(name="mycoolimage")

anyscale.image.register

Registers a BYOD image with a container image name.

Returns the URI of the image.

Arguments

  • image_uri (str): The URI of the BYOD image to register.
  • name (str): Name for the container image. If the name already exists, a new version will be built. Otherwise, a new container image will be created.
  • ray_version (str | None) = None: The Ray version (X.Y.Z) specified for this image specified by either an image URI or a containerfile. If you don't specify a Ray version, Anyscale defaults to the latest Ray version available at the time of the Anyscale CLI/SDK release.
  • registry_login_secret (str | None) = None: Name or identifier of the secret containing credentials to authenticate to the docker registry hosting the image.

Returns: str

Examples

import anyscale

image_uri: str = anyscale.image.register("docker.io/myuser/myimage:v2", name="mycoolimage")

Image Models

ImageBuild

ImageBuild(uri: str, status: Union[str, anyscale.image.models.ImageBuildStatus], ray_version: Optional[str])

Fields

  • uri (str): The URI of the image for the build.
  • status (str | ImageBuildStatus): The status of the image build.
  • ray_version (str | None): The Ray version used for the image build.

Python Methods

def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""

Examples

import anyscale
from anyscale.models import ImageBuild, ImageBuildStatus

image_build: ImageBuild = anyscale.image.get("image-name")

ImageBuildStatus

An enumeration.

Values

  • IN_PROGRESS: The image build is in progress.
  • SUCCEEDED: The image build succeeded.
  • FAILED: The image build failed.
  • UNKNOWN: The CLI/SDK received an unexpected state from the API server. In most cases, this means you need to update the CLI.