Using Custom Images
Scenarios
You can use the Spark or Flink basic images provided by DLI to package the dependencies (files, JAR packages, or software) required into an image using Dockerfile, generate a custom image, and release the image to SWR. On the DLI job editing page, select the generated image and run the job. You can embed private capabilities into custom images to enhance the functions and performance of jobs.
Restrictions
- Only containerized queues are supported.
- Only JAR jobs (user-defined Spark and Flink jobs) are supported.
Procedure for Creating a Custom Image
The following describes how to package TensorFlow into an image to generate a custom image with TensorFlow installed. Then, you can use the image to run jobs in DLI.
- Obtain basic images.
Run the following command to obtain the basic image.
Syntax:
docker pull [SWR repository address]/[organization name]/[image name]:[image tag]
Example:
docker pull swr.cn-north-1.huaweicloud.com/dli/spark:2.3.2-1.0.0-euler-2.9-x86_64
Table 1 Basic images Organization Name
Image Name
Image Tag
dli
spark
2.3.2-1.0.0-euler-2.9-20.04-x86_64
2.3.2-1.0.0-euler-2.9-aarch64
flink
1.10-1.0.0-euler-2.9-x86_64
1.10-1.0.0-euler-2.9-aarch64
Image naming description:
<swr-registry>/<org>/<compoent>:<component-ver>-<imagever>-<os>-<os-ver>-<arch>
- swr-registry: SWR repository address, for example, swr.cn-north-1.huaweicloud.com.
- org: Organization name. The default value is dli.
- component: Image name, the value can be spark or flink.
- component-ver: Image version. The value for Spark is 2.3.x or 2.4.x and for Flink is 1.10
- imagever: 1.0.0, in ascending order
- os: Euler
- os-ver: OS version
- arch: x86_64 or aarch64
- Write a Dockerfile.
An example of the Dockerfile content is as follows:
ARG BASE_IMG=spark:latest FROM ${BASE_IMG} as builder USER root RUN set -ex && \ mkdir -p /root/.pip && \ echo "[global]" >> /root/.pip/pip.conf && \ echo "index-url = https://mirrors.huaweicloud.com/repository/pypi/simple" >> /root/.pip/pip.conf && \ pip3 install --user --no-cache-dir tensorflow==1.13.1 FROM ${BASE_IMG} USER root COPY --from=builder --chown=omm:ficommon /root/.local /home/omm/.local USER ommThe following steps are included:
- Set the available repository address of pip.
- Use pip3 to install the TensorFlow algorithm package.
- Copy the content in the temporary image builder where the algorithm package is installed to the basic image (this step is to reduce the image size) to generate the final custom image.
- Use Dockerfile to generate a custom image. Format of the image packaging command:
docker build -t [Organization name]/[Image name]: [Image version] --build-arg BASE_IMG= [DLI basic image path] -f Dockerfile
The following is an example of the image packaging command:docker build -t mydli/spark:1.0 --build-arg BASE_IMG=swr.cn-north-1.huaweicloud.com/dli/spark:2.3.2-1.0.0-euler-2.9-x86_64 -f Dockerfile .
- Upload the custom image to the SoftWare Repository for Container (SWR) service. SWR provides two upload modes:
- Uploading an image through a container engine client
- Access SWR.
docker login -u xxxxxx@xxxxxxx -p xxxxxxxxxxxxx
- Tag the Spark image by running the following command:
docker tag [Image name:tag] [Image repository address]/[Organization name]/[Image name:tag]
Sample command:
docker tag mydli/spark:1.0 swr.cn-north-1.huaweicloud.com/mydli/spark:1.0
- Push the image to the image repository.
docker push [Image repository address]/[Organization name]/[Image name:tag]
Sample command:
docker push swr.cn-north-1.huaweicloud.com/mydli/spark:1.0
For details about how to upload an image using a client, see the SoftWare Repository for Container User Guide.
- Access SWR.
- Uploading an image through SWR console
For details about how to upload images on the page, see the SoftWare Repository for Container User Guide.
- Uploading an image through a container engine client
- When submitting a Spark or Flink JAR job in DLI, select a custom image.
- Open the Spark job or Flink job editing page on the management console, select the uploaded and shared image from the custom image list, and run the job. If no shared image is available, click Authorize and set related parameters to run the job. Figure 1 Selecting a custom image on the DLI Spark job editing page
Figure 2 Selecting a custom image on the DLI Flink Jar job editing page
- Specify the image parameter in job parameters on API to use a custom image to run a job. For details about Spark jobs, see Creating a Batch Processing Job. For details about Flink JAR jobs, see Creating a Custom Flink Job.
- Open the Spark job or Flink job editing page on the management console, select the uploaded and shared image from the custom image list, and run the job. If no shared image is available, click Authorize and set related parameters to run the job.
Last Article: Downloading a Basic Image
Next Article: Basic Image Components

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.