Skip to Content

Create Training and Serving Docker Images (Postman)

0 %
Create Training and Serving Docker Images (Postman)

Create Training and Serving Docker Images (Postman)

Requires Customer/Partner License
October 11, 2021
Created by
October 10, 2021
Learn to build Docker images and orchestrate their execution with for SAP AI Core.

You will learn

  • Build Docker images and host on Docker Repository
  • Write ML Pipeline via Workflows.
QR code

Step 1: Create ML Code and Dockerfile

Docker will be used to store python code in form of containers (portable environments).

Create following files (download link below) as-it-is. Resulting directory structure may look like following:

folder structure

File Links

Training Scripts

train/ Download Link
Dockerfile Download Download
requirements.txt Download Download

Inference/ Serving Scripts

infer/ Download Link
Dockerfile Download Download
requirements.txt Download
Log on to answer question
Step 2: Build Docker image
  1. Execute following line on terminal, to connect to you Docker account.
    Edit the highlighted line

    docker login -u <your-dockerhub-username>

  2. Type your password (nothing will appear on screen: just type your password and press enter)

    docker login
  3. Navigate to place where you have stored the code files.

  4. Navigate inside train

    cd train
  5. Build Docker image (change the highlighted line).

    docker build -t <your-dockerhub-username>/text-clf-train:0.0.1 .
    docker build train

Similarly navigate inside infer folder and execute the following command to build docker image for serving the model.:

docker build -t <your-dockerhub-username>/text-clf-serve:0.0.1 .
docker build infer
Log on to answer question
Step 3: Upload Docker image to Docker repository

Push your local docker image to Docker Hub cloud.

Execute the following on you terminal. (change the highlighted line)

docker push<your-dockerhub-username>/text-clf-train:0.0.1

(sample image if previously uploaded)

docker push

Similarly push your serving docker image. (change the highlighted line).

docker push<your-dockerhub-username>/text-clf-serve:0.0.1

Visit, inside the repository text-clf-serve you will see you uploads.

docker uploads
Log on to answer question
Step 4: Create Workflow Files

Workflows will instruct SAP AI Core
- how to execute the docker images
- what inputs to provide(datasets)
- what outputs it gives.

(Further read ArgoWorkflows )

Create a folder workflows inside to your cloned local GitHub folder.

Create the following file (download links below) as depicted in the image

Download Files

File Link
training_workflow_tutorial.yaml Download
serving_workflow_tutorial.yaml Download
workflow GitHub local
Log on to answer question
Step 5: Choose computing hardware resources

Inside YAML files from previous step find the line

  ... starter

The starter is the computing resource plan is used in this tutorial. Below is the list of other available plans offered by SAP AI Core.

resourcePlan ID GPUs CPU cores Memory (Gb)
Train-L 1 V100 GPU 5 47
Infer-S 1 T4 GPU 3 10
Infer-M 1 T4 GPU 7 25
Infer-L 1 T4 GPU 15 55
Starter 1 2.5
Basic 3 10
Basic.8x 31 115
Log on to answer question
Step 6: Add Docker details to workflows

Edit the following lines (highlighted) in each workflow file (YAML).

  • training_workflow_tutorial.yaml
    	image: "<your_docker_repo_url>/<your_username_in_docker_repo>/text-clf-train:0.0.1"

train docker image yaml

  • serving_workflow_tutorial.yaml
    					image: "<your_docker_repo_url>/<your_username_in_docker_repo>/text-clf-serve:0.0.1"

train docker image yaml

Log on to answer question
Step 7: Upload workflows to GitHub repository
  1. Copy the workflows folder (from previous step) to your cloned local GitHub folder. Ensure your files are placed as per image below

    workflow GitHub local
  2. Open GitHub Desktop.

  3. Type the commit message workflows added. And click on Commit to main button.

    GitHub commit
  4. Click on Push origin.

    GitHub push

Now SAP AI Core will automatically sync workflows from your GitHub through the Applications.

IMPORTANT: The SAP AI Core syncs in interval of 3 minutes.

Log on to answer question
Step 8: API to check workflow sync status

IMPORTANT: WAIT ATLEAST 3 MINS before sync is done.

Check the sync status of your workflows with postman.

ADD POSTMAN Environment Variable

Key Value
appName aicore-test-app
add environment variable

COLLECTIONS > admin > applications > GET get application status





(if 404, See troubleshooting below.)

    "healthStatus": "Healthy",
    "message": "successfully synced (all tasks run)",
    "reconciledAt": "2021-09-27T03:16:41Z",
    "source": {
        "path": "workflows",
        "repoURL": "",
        "revision": "8505d9235fc19f672096e22354a934e429dad9a3"
    "syncFinishedAt": "2021-09-27T03:16:41Z",
    "syncRessourcesStatus": [
            "kind": "WorkflowTemplate",
            "message": " configured",
            "name": "text-clf-train-tutorial",
            "status": "Synced"
    "syncStartedAt": "2021-09-27T03:16:40Z",
    "syncStatus": "Synced"
get app status


  1. "message": "KeyError : 'operationState'"

    Your repository folder is empty from last sync. Wait for 3 minutes after uploading something to GitHub.

  2. "message": "Error retrieving status for application aicore-test-app"

    Unable to reach out application(SAP AI Core) named aicore-test-app, check if you have registered the GitHub directory as application.

Log on to answer question
Step 9: Summary

A small recap of what has been done so far.

  • The training and serving docker images are pushed to the docker repository
  • The training and serving workflows(*templates*) are uploaded to the GitHub repository.
AIF Setup
Navigate to Authorization Tab in Postman. Select the Type which will be going to use `token` from environment variable.

Next Steps

Back to top