Image API Reference (0.26.91)
Image API Reference (0.26.91)
This is archived documentation for version 0.26.91. For the current documentation, see current documentation.
Customer-hosted cloud features
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
- CLI
$ 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.
-j/--json: Output as JSON.--yaml: Output as YAML.-v/--verbose: Show all fields including IDs and metadata.
Examples
- CLI
$ anyscale image get -n my-image
uri: anyscale/image/my-image:1
status: SUCCEEDED
ray_version: 2.21.0
anyscale image list
Usage
anyscale image list [OPTIONS]
List images.
Options
--image-id/--id: ID of the image to display.--name/-n: Substring to match against the image name.--image-name: Substring to match against the resolved image URI (BYOD images only).--project: Filter images by project name.--created-by-me: List images created by me only.--include-archived: Include archived images in the results.--include-anonymous: Include anonymous (workspace-scoped) images.--max-items: Max total items (only with --no-interactive).--page-size: Items per page (max 50).--interactive/--no-interactive: Use interactive paging.-j/--json: Emit structured JSON to stdout.-v/--verbose: Show all fields including IDs and metadata.
Examples
- CLI
$ anyscale image list --no-interactive --max-items 2
NAME LATEST VERSION LATEST URI CREATED BY CREATED AT
my-image 3 anyscale/image/my-image:3 dhyey@anyscale.com 2024-12-01 18:42
workspace 1 anyscale/image/workspace:1 joshlee@anyscale.com 2024-11-09 09:15
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.--cloud-id: The ID of the Anyscale Cloud to associate this image with. Required for Azure Control Plane only.
Examples
- CLI
$ 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
anyscale image archive
Usage
anyscale image archive [OPTIONS]
Archive an image and all of its versions.
Options
--name/-n: Name of the image to archive. Can include an optional version tag (e.g., 'name:version').
Examples
- CLI
$ anyscale image archive --name my-old-image
(anyscale +0.5s) Successfully archived image.
Image 'my-old-image' archived successfully.
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
- Python
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
- Python
import anyscale
image_status = anyscale.image.get(name="mycoolimage")
anyscale.image.list
List images or fetch a single image by ID.
Arguments
image_id(str | None) = None: If provided, returns just the image with this ID wrapped in a one-page iterator.name(str | None) = None: Substring to match against the image name.image_name(str | None) = None: Substring to match against the resolved image URI (BYOD images only).project(str | None) = None: Name of the project that owns the image.creator_id(str | None) = None: Filter images by the creator user ID.include_archived(bool) = False: Include archived images (default: False).include_anonymous(bool) = False: Include anonymous (workspace-scoped) images (default: False).max_items(int | None) = None: Maximum total number of items to yield (default: iterate all).page_size(int | None) = None: Number of items to fetch per API request (default: API default).
Returns: ResultIterator[ImageBuild]