Environments (Docker images)
Apolo uses Docker containers to run jobs in isolated environments. To run a container, you need to use Docker images that are templates containing an application and all the dependencies to run that application. Thus, a Docker container is a running instance of a Docker image.
Apolo lets you use Docker images either from the public Docker registry (such as Docker Hub) or from a platform's cluster registry (also called a private repository). Every cluster has one platform registry, reusing images from one cluster in another cluster requires copying this image using apolo-extras
.
In these tutorials, we will use a sample project - Nero-Assistant - to understand the available options. Before you can work in an environment, make sure that you have initialized a new flow (see the Getting Started guide for details).
How do I run a job using a container image from a public registry?
You can run jobs from images both on the public Dockerhub registry and on the platform registry. You can use the apolo run
command to run a job:
apolo run [OPTIONS] IMAGE -- [CMD]
Parameters
Name | Description |
IMAGE | The full URI of the image on which you want to run the command. |
[CMD] | The commands that you want to pass to the container. |
Sample output
Note: The job name that you provide must contain only lowercase letters, number, or hyphens; and must begin with a letter.
When a job is created, it is added to the queue and its status is set to Pending. Once the job starts running, a job ID is assigned to it, and its status is set to Running. All current jobs are also listed on the Apolo web interface.
For more information, see the CLI's #run command reference.
You can view the list of jobs currently running using the command: apolo ps
. This also lists the ID of the jobs. You can terminate a job using the command: apolo kill <job ID>
.
How can I view all images that I have access to?
Apolo lets you create multiple images, and you can view information about the images that you own or have access to from the command prompt. To view all images, you must run the following command:
apolo image ls [OPTIONS]
Sample Output
You can view the tags for an image by running the command:
apolo image tags [OPTIONS] IMAGE
Sample output
Note that you must provide the full URI to view tags for an image. You may want to add tags when you push an image or save an image. For more information, see Apolo CLI image #tagscommand reference.
How can I upload a custom image to the platform registry?
Apolo provides a base public Docker image based on deepo. You can customize the base image by installing or configuring packages, or updating settings by providing the docker engine instructions. You can pass instructions for image customization using Dockerfile.
Apolo lets you upload your custom images to the platform and then use them to run jobs. You can also share these custom images with your co-workers. It's a best practice to add tags to your image for better tracking.
To upload a custom image, run the following command:
apolo image push [OPTIONS] LOCAL_IMAGE [REMOTE_IMAGE]
Parameters
Name | Description |
LOCAL_IMAGE | The local container image that you want to upload. |
REMOTE_IMAGE | The remote image to which you want to upload. The image name should start with “image:” |
Sample Output
After pushing the image, run the apolo image ls
command to check if the push has worked. If the push was successful, you should see the local image as well as the platform image.
How can I save a running job as a custom image?
There are several ways in which you can create custom images. One of them is creating a custom image from a running job. Before you save a job, you must know its ID or name.
You can use the apolo job save
command to save a job as a custom image:
apolo job save [JOB] [IMAGE]
Parameters
Name | Description |
JOB | The ID or name of the job that you want to save as a custom image. |
IMAGE | The commands that you want to pass to the container. |
Sample output
We have saved the job job363 as a custom image ubuntu-custom.
How can I use an image from a platform registry?
Apolo lets you work with jobs, environments, and storage. Jobs are run on environments (or containers) that are isolated with their own storage, CPU, and memory. You can run jobs both on the public Docker registry or a platform registry. To better manage your resources, you can specify the CPU and the amount of memory the job will use.
You can use the apolo run
command to run a job:
apolo run [OPTIONS] IMAGE -- [CMD]
Parameters
Name | Description |
IMAGE | The full URI of the image on which you want to run the command. |
[CMD] | The commands that you want to pass to the container. |
Sample output
We have run a named job job363 using a small CPU resource preset on the patched ubuntu image.
How can I download an image from the platform registry?
Apolo lets you pull images from the platform registry. You can specify tags of the images to pull a certain tag; else, the image with the latest tag is pulled.
To pull an image from the platform, run this command:
apolo image pull [OPTIONS] REMOTE_IMAGE [LOCAL_IMAGE]
Parameters
Name | Description |
REMOTE_IMAGE | The remote image that you want to pull. |
[LOCAL_IMAGE] | The local custom image that you want to pull to. |
Sample Output
How can I share custom images with my teammates?
First of all, refer to Projectsdescription, inviting teammates into projects simplifies collaboration. However, of a ad-hock share is required, proceed reading.
Apolo lets you share your custom image with your team without having to upload the image to a platform. You could opt to push your custom image to the public registry if you want to share your container image with a large audience.
To share your image, run the command:
apolo share [OPTIONS] URI USER [read|write|manage]
The permissions you may give the user for the shared image:
Read: The user can only pull the image or run job using it and can't make any changes.
Write: Provided user can make changes to the image or even remove it.
Manage: The user can share the image.
Sample command
Operations with images from other clusters
All operations that were described earlier can be performed with images from other clusters.
For example, to push a local neuromation-nero-assistant
image to the platform registry on the <cluster-name>
cluster into <proj>
project that is within <org>
organization hit:
Last updated