Docker is an open platform, that gives customers the ability to deploy, multiple o/s containers on any give host. This allows for the deployment of multiple environments without having to incur the overhead of having a virtual machine per environment. Docker uses linux o/s facilities like namespaces, cgroups and union capable file systems to deploy lightweight containers.
A good explanation of Docker Architecture and concepts can be found here.
At the time of writing of this post, oracle does not support running oracle databases in docker containers. However it is conceivable that, in the future customers might want to deploy the oracle database in a docker container’s on the cloud. It could be an effective mechanism to create and maintain a large number of database copies in order to support development environments that follow agile development methadologies.
Update Jan 03 2017 : Oracle now supports running oracle databases in docker containers. Please see Mos note 2216342.1 for details.
Oracle has published docker images for Oracle Linux 6 and Oracle Linux 7. Recently Oracle has also published a DockerFile and a build script that builds a docker image that uses Oracle Linux 7, installs and creates a oracle database (11gr2 or 12cr1) on it, and creates a new image that includes the oracle database. This is an easy way to get an oracle 188.8.131.52 database up and running for development purposes.
In this blog post, I will detail the steps i followed to build an Oracle 12c database, Docker image, that runs inside of a VirtualBox virtual machine.
The high level steps are as follows.
- Download the oracle 12cr1 installation Files.
- Download and setup a VirtualBox Ubuntu 16.04 image from osboxes.
- Install docker on Ubuntu 16.04
- Download the Oracle Docker files from github
- Stage the 12cr1 binaries Execute the build script to build the Oracle database docker image.
Download the oracle 12cr1 installation files.
- Login to edelivery.oracle.com
- Choose Oracle Database Enterprise Edition, and Linux x86-64
- Choose the 2 files, and download them.
- Rename (Because the Docker build script expects files to be with these names) the files as shown below
- V46095-01_1of2.zip to linuxamd64_12102_database_1of2.zip
- V46095-01_1of2.zip to linuxamd64_12102_database_2of2.zip
Download and setup a VirtualBox Ubuntu 16.04 image from osboxes
From www.osboxes.org/ubuntu, download the .vdi file, for “VirtualBox (VDI) 64Bit”.
The downloaded file name will be Ubuntu-16.04-Xenial-VB-64bit.7z. Unzip the contents of this file, to any directory. This will give you a file named “Ubuntu 16.04 64bit.vdi”
From your VirtualBox console create a new VirtualMachine.
- Use the expert mode
- Name “Ubuntu1604”
- Type “Linux”
- Version – “Ubuntu (64-bit)”
- Choose 3Gb of memory for the virtualmachine.
- Choose “Do not add a virtualdisk”
- Click Create
- Copy the file you downloaded from www.osboxes.org, “Ubuntu 16.04 64bit.vdi” into the newly created directory, named “Ubuntu1604”
- This brings you back to the home page.
- Choose the newly created image “Ubuntu1604”, click on Storage, and Click on “Controller SATA”.
- Here choose to add a new disk, and choose the file “Ubuntu 16.04 64bit.vdi”.
- Click OK.
- This brings you back to the home page.
- Click on Network.
- The Network Adapter 1, is configured to use NAT, change this to use “Bridged Adapter”, Click Ok.
Now you have a virtualmachine, which runs the latest version of Ubuntu. The / directory has 99GB of space allocated to it, and hence is sufficient to create the oracle docker image.
Start the virtualmachine and login. (The default user it creates is osboxes, and the password is osboxes.org)
Install docker on Ubuntu 16.04
Follow the instructions at https://docs.docker.com/engine/installation/linux/ubuntulinux/, to install docker.
- login as the user osboxes into Ubuntu
- Invoke a linux terminal.
- sudo su –
- apt-get update
- apt-get install apt-transport-https ca-certificates
- apt-key adv –keyserver hkp://p80.pool.sks-keyservers.net:80 –recv-keys 58118E89F3A912897C070ADBF76221572C52609D
- vi /etc/apt/sources.list.d/docker.list
- Add the following line
- deb https://apt.dockerproject.org/repo ubuntu-xenial main
- save and quit
- apt-get update
- apt-cache policy docker-engine
- apt-get install linux-image-extra-$(uname -r)
- apt-get install docker-engine
- sudo service docker start
- sudo groupadd docker
Create a new o/s user for running docker images.I will be performing all the docker operations going forward, from this OS User.
- I created a new o/s user named rramdas (Regular user, not admin) (Feel free to create a user with any name you want to use)
- I added this user to the sudoers file, so I can sudo to root from this user.
- Add the new user rramdas to the docker group
- sudo usermod -aG docker rramdas
Login as rramdas and ping yahoo.com to ensure that you are able to communicate with machines on the internet.
Next I installed opensshd-server so that I can ssh to this virtual host from my laptop. (Not required)
Download the oracle Docker files from github
- Login as rramdas
- Create a directory /u01 in which we will place all the docker files
- sudo su –
- mkdir /u01
- chown rramdas:rramdas /u01
- cd /u01
- git clone https://github.com/oracle/docker-images
- cd /u01/docker-images
- remove all the directories other than OracleDatabase.
Stage the 12cr1 binaries
From the directory where the oracle installation binaries were downloaded in step 1.
- Copy the oracle installation binaries to the virtual host. (10.1.1.156 is the Ip address of my virtual host)
- scp linuxamd64_12102_database_* email@example.com:/u01/docker-images/OracleDatabase/dockerfiles/184.108.40.206/.
We are staging the oracle installation files in this directory because the Docker build script expects the files in this directory.
Build the Docker Image with Oracle 12c
- login as rramdas to the ubuntu virtualhost.
- cd /u01/docker-images/OracleDatabase/dockerfiles
- ./buildDockerImage.sh -v 220.127.116.11 -e -p manager -i
It Took 43 minutes to build the image.
If we take a deeper look into the DockerFile.ee, we can see that the following actions have been executed.
- Download the latest docker image for Oracle Linux
- Create the necessary O/S users and groups.
- Install the oracle-rdbms-server-12cR1-preinstall rpm, which checks and installs all the pre-requesite rpm’s for an oracle install and sets up the required kernel parameters.
- Runs the Universal Installer (Using a response file) to install the oracle binaries and create an oracle database.
- Creates the oracle listener and tnsnames entries.
After the script completes execution, we have a new docker image database:18.104.22.168-ee
Start the Docker database container.
You can start the Docker container using the command docker run -p 1521:1521 -p 5500:5500 oracle/database:22.214.171.124-ee
Now we have a 12c CDB, with 1 PDB running, in the Docker Container.
You can list the running docker containers using the “docker ps” command
This database can be accessed from any oracle database client (like sqlcl or sqlplus, or any application via jdbc , odbc etc).
This should get you started with using an Oracle 12c database in a Docker container.