Welcome!

Blog Feed Post

Dockerizing Your Development and Test Oracle databases

You are probably reading this blog because your application depends on Oracle database. Most enterprises in the world depend on Oracle database to run their business. If you are a developer using Oracle database and getting started with Docker, you must be wondering how can you use a containerized Oracle database. 

In my last blog, I outlined how you can use a Dockerized Tomcat /Tom EE with an Oracle database. In this blog, I will describe how you can use Dockerized Oracle database for your development or test activities.

If you want to get started with Docker, review their getting started guide.

Getting Docker Images

Oracle provides Docker images for Oracle Database and you don't have to build using Dockerfile. You can get Oracle Database Docker images either from Docker store or Oracle Container Registry.

You have to register and accept licenses in Docker store or Oracle Container Registry.

In this blog, I will outline the steps required for the Docker image downloaded from Oracle Container Registry.

Login to Container-Registry 

You can log in to the Oracle Container Registry as follows:

docker login container-registry.oracle.com
Username :      
Password:

The Oracle Container Registry provides option to  download images for Oracle Standard or Enterprise Edition (12.2.0.1).

Note that the download may take several minutes or up to couple of hours based on your internet bandwidth. 

Download Oracle Database EE

If you want to download the docker image for Oracle Database Enterprise Edition, you can use the Docker pull command as follows:

docker pull container-registry.oracle.com/database/enterprise:12.2.0.1


You will get output as below if the your command is successful:

12.2.0.1: Pulling from database/enterprise
cbb9821ba51c: Downloading [>                                                  ]  1.599MB/81.5MB
9bd4d110366e: Downloading [>                                                  ]  1.067MB/143MB
af8b29651e27: Download complete 
4c242ab1add4: Download complete 
7bda1e55bd08: Downloading [>                                                  ]  1.599MB/2.737GB

Download Oracle Database SE

In my example, I am going to use Oracle Database Standard Edition. You can download the image for Oracle DB SE as below:

docker pull container-registry.oracle.com/database/standard

You will see output as below:

Using default tag: latest
latest: Pulling from database/standard
Digest: sha256:fad41f7b4b885f13943872218a73c7f051e2caed0b5d5620d8f6f1287cf44918
Status: Image is up to date for container-registry.oracle.com/database/standard:latest

Download Issues

You will get authentication errors if you have not logged to the Docker registry.

Ensure that you accepted the Oracle license agreement in the Oracle Container Registry, otherwise you will get an error message as below:

Error response from daemon: pull access denied for database/standard, repository does not exist or may require 'docker login'

Checking Docker Images

You can check Docker images available by using the following command:

docker images | grep oracle


container-registry.oracle.com/java/serverjre           8                   daea2cf635d1        5 weeks ago         280MB
container-registry.oracle.com/database/instantclient   latest              fda46de41de3        4 months ago        407MB
container-registry.oracle.com/database/standard        latest              faa877d7fbdd        7 months ago        5.16GB

DB Config file

The Oracle DB container requires a configuration file where you can specify few parameters such as Database SID, Password, etc.

Here is the db.properties file that I used. As you can see I changed the default password and the domain for my database.


DB_SID=ORCL

## db passwd
## default : Oracle

DB_PASSWD=welcome1

## db domain
## default : localdomain

DB_DOMAIN=us.oracle.com

## db bundle
## default : basic
## valid : basic / high / extreme
## (high and extreme are only available for enterprise edition)

DB_BUNDLE=basic


Starting Database Container

You can start the Database container by using the command as shown below. If you have not downloaded the database image, then database image will be automatically pulled from the container repository. 
            

docker run -d --env-file db.properties -p 1521:1521 -p 5500:5500 --name orcldb --net appnet  --shm-size="4g" -v /Users/dpanda/orderapp2/orcl:/u04/app:/u04/app container-registry.oracle.com/database/standard

The container will start and database will be ready to use within few minutes.

Reviewing Key Parameters 


Let’s review some of the key parameters I specified.

·       The --shm-size="4g" parameter sets the size of shared memory i.e. /dev/shm for the container to 4GB. 

·       The --name orcldb parameter sets the name of the container to orcldb. You can login to the container with that name or other containers can communicate to this container in that name when using SQLNet or JDBC. You can use this name to stop or remove the container.

·       The --net appnet is connecting the container to the bridge network named appnet.

·       The -v /Users/dpanda/orderapp2/orcl:/u04/app option lets the container map the /u04/app drive to the local volume (/Users/dpanda/orderapp2/orcl) of my MAC. This mapping allows the database to create the redo logs into my local drive. Also this will enable me run the SQL scripts that I have in my local drive to run inside the container.

You can check the status of the running containers by using the docker ps command as below:


CONTAINER ID        IMAGE                                             COMMAND                  CREATED             STATUS              PORTS                                            NAMES
9101006044e9        container-registry.oracle.com/database/standard   "/bin/sh -c '/bin/..."   2 minutes ago       Up 2 minutes        0.0.0.0:1521->1521/tcp, 0.0.0.0:5500->5500/tcp   orcldb
fccce8035b91        orderapp                                          "catalina.sh run"        46 hours ago        Up 46 hours         0.0.0.0:8080->8080/tcp

As you can see, the orcldb container running my Oracle database started up 2 minutes ago.                           

Executing Commands in the Container

Now that the container is running you can run commands inside the container by executing docker exec command

You can login to the container as below and check whether things are set properly.

Note that these are purely optional steps and are not required.

1. Login to the Container

docker exec -it orcldb /bin/bash

2. Switch Linux user to oracle user from root

su – oracle

Last login: Sat Jan 13 05:50:33 UTC 2018 on pts/0

3. You can check few things such as Oracle Environment Variables

 echo $ORACLE_SID
ORCL

 echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0/dbhome_1

4. Connect to SQLPlus 

sqlplus sys/welcome1 as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Sat Jan 13 07:03:14 2018

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


Connected to:
Oracle Database 12c Standard Edition Release 12.1.0.2.0 - 64bit Production

SQL> 


Accessing the Oracle Enterprise Manager Database Console



You can access the EM Console as https://localhost:5500/em

You can login with the user id as sys or system and password you specified in the db.properties file while starting the container. 




After you login you will see the Database Home Page as below. You can see the name of your container as your database host.



Your Dockerized Oracle Database is now ready for use! 


Try exploring until I next time !  We will see how you can run use SQLPlus with the Dockerized database.

Read the original blog entry...

More Stories By Debu Panda

Debu Panda is a Director of Product Management at Oracle Corporation. He is lead author of the EJB 3 in Action (Manning Publications) and Middleware Management (Packt). He has more than 20 years of experience in the IT industry and has published numerous articles on enterprise Java technologies and has presented at many conferences. Debu maintains an active blog on enterprise Java at http://debupanda.blogspot.com.

Latest Stories
DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Conference Guru has been named “Media Sponsor” of the 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. A valuable conference experience generates new contacts, sales leads, potential strategic partners and potential investors; helps gather competitive intelligence and even provides inspiration for new products and services. Conference Guru works with conference organizers to pass great deals to gre...
DevOps is under attack because developers don’t want to mess with infrastructure. They will happily own their code into production, but want to use platforms instead of raw automation. That’s changing the landscape that we understand as DevOps with both architecture concepts (CloudNative) and process redefinition (SRE). Rob Hirschfeld’s recent work in Kubernetes operations has led to the conclusion that containers and related platforms have changed the way we should be thinking about DevOps and...
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform. In his session at @ThingsExpo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and shared the must-have mindsets for removing complexity from the develop...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
The next XaaS is CICDaaS. Why? Because CICD saves developers a huge amount of time. CD is an especially great option for projects that require multiple and frequent contributions to be integrated. But… securing CICD best practices is an emerging, essential, yet little understood practice for DevOps teams and their Cloud Service Providers. The only way to get CICD to work in a highly secure environment takes collaboration, patience and persistence. Building CICD in the cloud requires rigorous ar...
Companies are harnessing data in ways we once associated with science fiction. Analysts have access to a plethora of visualization and reporting tools, but considering the vast amount of data businesses collect and limitations of CPUs, end users are forced to design their structures and systems with limitations. Until now. As the cloud toolkit to analyze data has evolved, GPUs have stepped in to massively parallel SQL, visualization and machine learning.
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
"ZeroStack is a startup in Silicon Valley. We're solving a very interesting problem around bringing public cloud convenience with private cloud control for enterprises and mid-size companies," explained Kamesh Pemmaraju, VP of Product Management at ZeroStack, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Enterprises are adopting Kubernetes to accelerate the development and the delivery of cloud-native applications. However, sharing a Kubernetes cluster between members of the same team can be challenging. And, sharing clusters across multiple teams is even harder. Kubernetes offers several constructs to help implement segmentation and isolation. However, these primitives can be complex to understand and apply. As a result, it’s becoming common for enterprises to end up with several clusters. Thi...