In this second post in my CloudFoundryFun series, I show you how to leverage Cloud Foundry to forge a new learning environment.
Forging a new learning environment with Jupyter Notebook
The top dog of all interactive learning platforms is by far the Jupyter project. This project has become the de-facto standard learning environment for data scientist around the world. This popularity originates from its close linkage to the languages Python and R.
Btw: did you know what Jupyter stands for “Julia, Python, and R”?
The rising popularity is also reflected by the number of
.ipynb files (interactive python notebook - the file format of Jupyter Notebooks) on GitHub.
The rising popularity of Python Notebook on Github (Source)
Notebooks are the core of each Jupyter project and the origin of its simplicity. The code contained in them can be partitioned in small code snippets. The special feature is that those snippets can be enriched with explanations written in
Markdown, a lightweight markup language. Beginners can execute the pre-defined snippets section by section. Each section is self-explanatory and thus, generates a unique learning environment.
An example of a Jupyter notebook with explanations and code next to each other
In this post we will run Jupyter Notebooks ON Cloud Foundry, thereby our notebooks will have access to Cloud Foundry services.
This way, we can learn how to use Cloud Foundry services using Jupyter Notebook, running on Cloud Foundry.
Bundling the Learning Environment
It might be worth bundling the Notebook app with your training content like notebooks and possibly required datasets. The bundling can be done using with a new Docker image. This Dockerfile shows how new content can be added to an existing image:
FROM jupyter/minimal-notebook
RUN rm -d work
RUN mkdir Lesson_1
COPY Lesson_1 ./Lesson_1
Publishing the Image
- Sign up for a Docker account on https://hub.docker.com and install docker
- Login via the command line
docker login
- Build the image from the Dockerfile
docker image build -t "cloudfoundryfun2" .
- Read the ID of your image
docker images

- Tag the newly created image
docker tag <Image ID> <Dockerhub User>/cloudfoundryfun2:latest
- Publish the image to Dockerhub
docker push <Dockerhub User>/cloudfoundryfun2:latest
Note: You can skip this step and use the
minimal-notebook if you don't want to add your own data to the image.
Combine the image with your Cloud Foundry Services
Similarly to my
last post, specify your image and the bound Cloud Foundry services in a mtad.yaml, the
descriptor file:
_schema-version: 3.2.0
ID: jupyter
description: Deploy jupyter notebooks in your SCP CF for learning purposes
version: 0.0.1
modules:
- name: jupyter-notebook
type: javascript.nodejs
path: .
requires:
- name: hana-service
parameters:
disk-quota: 4G
memory: 3G
docker:
image: <Your Dockerhub User>/cloudfoundryfun2:latest
resources:
- name: hana-service
type: com.sap.xs.hdi-container
properties:
hdi-container-name: ${service-name}
parameters:
service: hanatrial
This docker container will be bound to an SAP Leonardo Machine Learning Foundation service and an HDI container.
Build the MTAR archive with the
cloud build tool.
mbt assemble
The structure of our bundle
Edit: The SAP Leonardo ML Foundation service in not available anymore.
Deploying the Notebook
Prerequisites:
Instructions:
- Use your MTAR
- Deploy the archive
cf deploy jupyter_0.0.1.mtar
This command outputs the URL of the running app.

- Access the Notebook
You’ll notice that you need a token to access the notebook. You can find it in the logs of your application.

- Read the logs
cf logs juypter-notebook –recent
Copy and paste the token into the corresponding field.

- Login to service
Open the notebook in the folder “Lesson_1” (if you added data to your own docker image)

- Have fun learning!

Disclaimer: I recommend using Jupyter Notebooks on Cloud Foundry only for educational purposes. The application itself runs on hardware that wasn’t designed for compute intense tasks (as machine learning is one).
Summary
In this edition you have learned:
- What Jupyter Notebooks are and where they come from
- How Docker images can be enriched with additional files
- How to publish your own Docker images to Dockerhub
- How to deploy Docker images along with cloud services to SAP Cloud Platform Cloud Foundry
- How to read the log files of your Cloud Foundry apps
Would you like to learn more about the detailed steps (with actual training content) in a tutorial in our Developer Center? Let me know in the comments!
About this series