Python - External Modules: Docker

In order to build your own Dockerfile.

For example to use tensorflow module:

  • The following file will be used as an entry point script:
File myapp.py
# Module import
import tensorflow as tf


# Use of module
def compute_mean(data):
    func = tf.reduce_mean(data)
    print(tf.Session().run(func))


# Script
if __name__ == '__main__':
    compute_mean(tf.constant([1, 5, 9, 6, 7]))

  • Then we create a Dockerfile:
Custom Dockerfile
FROM saagie/python:3.5.2-1.3.1-centos

RUN pip install tensorflow

ADD myapp.py .

CMD ['bash', '-c', 'python', 'myapp.py']

You can use any of Saagie's public python images as the base image.

The list of Saagie's python images is available: Here

  • We create a Docker image in a repository that is accessible to Saagie platform:
Building and pushing a Docker image
docker build . -t repo/myImage:mytag

docker push repo/myImage:mytag
  • Finally a Docker job has to be created on the platform with the image:
Image name
repo/myImage:mytag