Skip to main content

Using Forklift

· 7 min read
Sujin Kim
Kangmin Kwon

What is Forklift?

Backend.AI's Forklift is a service that automatically generates Docker container images for use in computational sessions and supports optimized deployment. It is very good news for those who need to configure image environments differently for each target device or who need to deploy but do not know how to write Docker files. With Forklift, you can easily build custom images by simply setting the source and target images.

Background of Forklift's Creation

With Backend.AI, you can use various functions in the compute session. Of course, Backend.AI provides preset images, but if you want to work with the image you were already using, you have to add Backend.AI-related settings to the image and rebuild it. Even for those who have knowledge about images, this process is cumbersome and complex. To solve this problem, the need for Forklift, which automatically builds images through GUI or OpenAPI, has emerged.

Building with Forklift

Forklift supports both OpenAPI and GUI environments. First, let's take a look at how to build in the GUI environment.

When you log into the Forklift service, you will see the screen as shown above. The Summary page has a Build button that takes you directly to the Build page in the upper left corner, and next to it is a chart that shows the status of the work done so far. Below, you can see what images the user has installed.

To build an image, click the BUILD button in the Start menu or click Builder in the side menu to go to the builder page as shown below.

Builder 페이지

Enter the base image in Source docker image and the newly created image based on the source image in Target docker image. For example, enter my.reg.com/test/ngc-tensorflow:19.07-py3, which includes the registry (my.reg.com), namespace (test), name (ngc-tensorflow), and tag (19.07-py3). Depending on the image, there may be no namespace. The source image must already be uploaded to the specified Docker registry (in this case, my.reg.com). (We plan to support the ability to use images on the host as the source image in the future.)

You can build it as it is, but you can customize it to the user's desired image by adding some options as shown below.

  • Resource constraints
    You can set options such as Minimum required CPU cores and Minimum required memory size to constrain the minimum resources required by the image you are creating.
  • Supported service ports
    When you specify a service port, a specific service is opened on a specific port of the container. Users can use services registered on service ports through the Backend.AI environment. For example, if you open Jupyter to port 8080 of the container using the HTTP protocol, when a user tries to run the Jupyter Notebook app, they will attempt to connect to port 8080. Of course, if Jupyter is not installed in the image, only the container port will be opened and the service will not be executed.
  • Set environment variable
    You can add simple (non-array) environment variables to be used inside the container.
  • Custom packages
    You can specify apt/pip/conda packages you want to install in advance.
  • Auto push docker image
    With the Auto push docker image option, you can push the newly created image to Docker Hub. The registry is specified in the Source docker image option.
  • Allow root
    Allowing the Allow root option allows regular users to use the sudo command to issue commands with root privileges.

Once you have completed all the settings, click the BUILD button at the bottom to start the build.

Checking building images

If you go to the Tasks page, you can check the 'Running/Pending/Completed/Error' images. The image below shows the appearance of 'testing:3.8-ubuntu18.04' built based on cr.backend.ai/stable/python:3.8-ubuntu18.04.

Running Image

If you click on the LOGS tab, you can see real-time logs on how the current build is progressing.

Streaming Logs

Since you have requested an image build, the Tasks chart on the Summary page has been updated, and the IMAGES tab in the Environments page shows the newly installed image.


Building with OpenAPI

You can also use Forklift via OpenAPI without using the GUI. Forklift's server is built on FastAPI1, which provides automatic documentation based on Swagger (OpenAPI). This allows you to easily use and test APIs.

OpenAPI

First, authentication is required to use the API. In the above picture, if you sign up through /register/ in the API, you can obtain authorization to use the API with the lock icon. If you have already signed up through the GUI, you can log in with the existing account by clicking the Authorize button in the upper right corner.

You now have the authority to build images. To build an image, use /build/general_submit/ and /build/preset_image/. The former allows users to customize images and build them, as explained in the GUI description above. The latter allows users to build images easily without customization using preset images provided by Backend.AI. /build/preset_image/ is still under development, so let's take a look at /build/general_submit/.

general_submit

If you look into the request body, it contains the information required to build images on the image build server. We will skip the explanation of each field as it has already been explained above.

Explanation for each field

By clicking on the 'try it out' button on the left side of build/general_submit/, set the values for each field according to the user and click the Execute button to send a POST request to the route to start the build by the image build server.


Since the image build process is done as a background task inside the server, users can immediately receive a response regarding the success or failure of the build request.

Response

Once the build is completed, you can check the built image by using the command "docker images".

docker images

Additional features include:

  • Status information and request confirmation for the image build schedule
  • Preview and download function of the Dockerfile used for image build
  • Functionality to check, delete, and inspect image lists generated on the host
  • Function to check currently running containers
  • Container commit function

Summary

In this article, we introduced Forklift, how to use it in GUI and OpenAPI.

In summary, Forklift provides a service that automatically builds images as a service that allows users to use various functions provided by the computation session by introducing images that users have in Backend.AI.

Lablup moves based on the philosophy of Make AI Accessible. Forklift also started with our motto "shouldn't users be able to easily build images?" We are still in the beta stage of the service, but we will develop various functions to make AI research and deployment easy from a user perspective.

1 FastAPI: Official documentation link