GeekSocket Plug in and be Geekified

Running Oracle database XE 11G using Docker

In our syllabus we have Advance Database Systems subject. We were instructed to use Oracle database for this. So I was searching for Oracle database EXpress edition 11g but I did not want to install it on my system directly. Size was large as well. Easy and fast solution was to search for container image of it and run it.

At DockerCon 2017 they announced that they will be providing official Docker images for their products. Even after searching I was not able to find official Docker image of Oracle database XE. What I found was a Docker image build by sath89 and decided to use that.

I have used Google Cloud Platform VM (CentOS 7) to run this, you can do this on your local machine too.


1. Setup Docker on your machine

Head over to this link and follow the instructions for your distro to install Docker CE on your system.

Once you install Docker don’t forget to start the docker.service

$ sudo systemctl start docker.service

2. Pull Docker image

Now let’s pull Docker image of Oracle database XE 11g

$ sudo docker pull sath89/oracle-xe-11g

This will download the image on your machine.


3. Run the Docker image

We will run the the image, this will create new container for our image.

$ sudo docker run -d --name "oradb" \
-v "/my/oracle/data:/u01/app/oracle" sath89/oracle-xe-11g

This will start the container with name oradb and map the host machine directory /my/oracle/data to the directory from container where Oracle database stores all data.

We are specifying -d to run this in background.

Note that we are not mapping the container’s ports 8080 and 1521 to host’s ports as we are only interested in using the SQL CLI on local machine.


4. Access SQL command line

To access the CLI of Oracle database it is necessary to have sqlplus.

We will use sqlplus from the container itself.

$ sudo docker exec -it oradb sqlplus system/oracle@//localhost:1521/xe

SQL*Plus: Release 11.2.0.2.0 Production on Tue Aug 29 18:02:05 2017

Copyright (c) 1982, 2011, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

SQL> 

This will execute command sqlplus system/oracle@//localhost:1521/xe inside the container and -it makes this interactive.


5. Stop the running container

Once you finish with your work don’t forget to stop the container and delete it.

$ sudo docker stop oradb
$ sudo docker rm oradb

Your data will remain as it is. Next time you have to just follow the steps 3, 4, 5.


You can find more details about this container image here

https://hub.docker.com/r/sath89/oracle-xe-11g

https://github.com/MaksymBilenko/docker-oracle-xe-11g

If you face any issues or have any suggestions feel free to comment down below.


Comments

Comments are not enabled on this site. The old comments might still be displayed. You can reply on one of the platforms listed in ‘Posted on’ list, or email me.