in Programming

Docker and Jupyer for Oracle

In this quick post I will show you how to create a Docker image with Jupyter notebook inside and the required modules to connect to Oracle.

If you are new to Docker please check the official site on how to install it, for us installation is out of scope.

Getting the image and running a container

To create the image can just pull it from docker hub:

docker pull gianx/docker_jupyter_oracle

If everything is ok, you can see your image running

docker images

To run a new container:

docker run -d -p 8888:8888 -v "/localfolder:/notebooks" gianx/docker_jupyter_oracle:latest

This command will start a container as a demon (non-interactive), exposing port 8888 and mapping the working directory to “/localfolder”.

At this point, just poin a browser to:

http://dockerip:8888

… where “dockerip” is the IP of your host if you are running Ubuntu or the IP of your Docker machine if you are running OS X or Windows.

A look at the Dockerfile

You can find the Dockerfile here: http://bit.ly/1I3cMHB

It uses a base Jupyter image which installs both Python2 and Python3 and on top of that it installs Oracle client by downloading it:

RUN curl -O http://repo.dlt.psu.edu/RHEL5Workstation/x86_64/RPMS/oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm
RUN curl -O http://repo.dlt.psu.edu/RHEL5Workstation/x86_64/RPMS/oracle-instantclient12.1-devel-12.1.0.1.0-1.x86_64.rpm

Then it installs Oracle client and both installs cx_Oracle for Python2 and Python3 by running:

RUN pip2 install requests cx_oracle 
RUN pip3 install requests cx_oracle

And as usal, that’s all!