Download and Start Docker

Docker is a widely used container solution. Please download and start Docker by following their guide.

Get PredictionIO and Dependencies Configuration

Starting from v0.13.0, Apache PredictionIO® starts to provide docker support for the production environment. Dockerfile and dependencies configuration can be found in the docker folder in the git repository.

1
2
git clone https://github.com/apache/predictionio.git
cd predictionio/docker

In this installation, we only need the docker sub-directory in the repository. One can use other tools to get the folder without cloning the whole project.

Build Docker Image

To build PredictionIO docker image, Dockerfile is provided in sub-directory pio.

1
docker build -t predictionio/pio pio

One will be able to build an image with tag prediction/pio:latest using the above command.

People can get PredictionIO image from Dockerhub through docker pull predictionio/pio. However, since the image cannot run without a properly configured storage, please follow the following steps to complete the installation.

Image prediction/pio hosted on Dockerhub is NOT regarded as an official ASF release and might provide a different PredictionIO version from your desired PredictionIO version. It is recommended to build the image locally other than pulling directly from Dockerhub.

Pull Images and Start

In this repository, PostgreSQL, MySQL, ElasticSearch, and local file system are supported with their corresponding configuration.

Supported storages are as below:

Event Storage

  • PostgreSQL, MySQL, Elasticsearch

Metadata Storage

  • PostgreSQL, MySQL, Elasticsearch

Model Storage

  • PostgreSQL, MySQL, LocalFS

One can use docker-compose -f to pull and start the corresponding services. More details are provided in this document.

Service Starting Sample

1
2
3
4
5
6
docker-compose -f docker-compose.yml \
    -f pgsql/docker-compose.base.yml \
    -f pgsql/docker-compose.meta.yml \
    -f pgsql/docker-compose.event.yml \
    -f pgsql/docker-compose.model.yml \
    up

In this examples, we pull and start predictionio/pio image with docker-compose.yml.

And pull postgres:9 image with pgsql/docker-compose.base.yml.

And config PostgreSQL to store our metadata, event, and model with pgsql/docker-compose.meta.yml, pgsql/docker-compose.event.yml, and pgsql/docker-compose.model.yml.

After pulling the images, the script will start PostgreSQL, Apache PredictionIO, and Apache Spark. The event server should be ready at port 7070, and one should see these logs in the command line interface.

1
2
3
4
5
...
pio_1       | [INFO] [Management$] Your system is all ready to go.
pio_1       | [INFO] [Management$] Creating Event Server at 0.0.0.0:7070
pio_1       | [INFO] [HttpListener] Bound to /0.0.0.0:7070
pio_1       | [INFO] [EventServerActor] Bound received. EventServer is ready.

Verifying Service

A command tool pio-docker is provided to invoke pio command in the PredictionIO container. Set pio-docker to default execution path and use status to check the current PredictionIO service with the following script.

1
2
$ export PATH=`pwd`/bin:$PATH
$ pio-docker status

One should be able to see the corresponding log in the following structure, and your system is ready to go!

1
2
3
4
5
6
7
8
9
10
11
[INFO] [Management$] Inspecting PredictionIO...
[INFO] [Management$] PredictionIO 0.13.0 is installed at /usr/share/predictionio
[INFO] [Management$] Inspecting Apache Spark...
[INFO] [Management$] Apache Spark is installed at /usr/share/spark-2.2.2-bin-hadoop2.7
[INFO] [Management$] Apache Spark 2.2.2 detected (meets minimum requirement of 1.3.0)
[INFO] [Management$] Inspecting storage backend connections...
[INFO] [Storage$] Verifying Meta Data Backend (Source: PGSQL)...
[INFO] [Storage$] Verifying Model Data Backend (Source: PGSQL)...
[INFO] [Storage$] Verifying Event Data Backend (Source: PGSQL)...
[INFO] [Storage$] Test writing to Event Store (App Id 0)...
[INFO] [Management$] Your system is all ready to go.

After the service is up, one can continue by changing pio to pio-docker for further deployment. More details are provided in this document.

Community Docker Support

More PredictionIO Docker packages supported by our great community.