Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Thursday, February 16, 2017

Oracle Linux 7 docker image update

Today I added few more utilities to my oracle linux 7 with utilities docker image.

New additions are:  jdk 1.8 and groovy 2.4.8

To pull you can use

docker pull vikceo/oraclelinux7withutils

Enjoy!

Friday, February 10, 2017

Docker for Beginners

Docker is the hottest celebrity in the tech World. Everyone around you might be jumping over it. And you might wonder what the hype is about?

In simplest form, I would say it is much like a virtulbox or vm but very light weight. Reason? It eliminates an entire OS layer and uses most of the required components from the host OS. I would let you read more firm definition from official docker documentation

I started playing with it very recently and thought to put up some very basic getting started steps. I am using a mac pro with Sierra 10.12.3 as host OS.

Installation


  1. Head over to https://docs.docker.com/engine/getstarted/step_one/#/docker-for-mac and just hit "Get Docker for Mac".
  2. Install like any other OSX app and you are done.
  3. As a confirmation you should see a whale icon in your mac toolbar.

Create Your First Image

Before you create your first docker image, lets check what we already have. 

images

This list out all the docker images you already have. e.g.
Above lists out the repository where image exists (if not pushed then local), a tag which works like a version, the unique image id. Instead of re-inventing the wheel you should first check if someone already created an image you need and published on docker hub. If not exactly what you want but may be a starting point that you can extend further.  To mention docker hub is like a marketplace where you can look for images built by other devs like you. You can simply pull these images if there exists one that does your job. Likewise, once you extend or customize and existing image, then you can push your flavor for other's use. To push or pull you would need to create a docker hub account.



For this post, we are extending a Oracle Enterprise Linux 7 image with some of the handy utilities/scripts. To do that, you need to pull the base image as the first step and then start downloading and installing the required utils/scripts. This sequence of steps need to be defined in a file called Dockerfile. To store your docker file and any additional resources, lets start with a new dir.


Create a text file and name it Dockerfile using your favorite editor. I use sublime. The very first instruction would be to pull the base image (Oracle Enterprise Linux 7 in this case). The file will look like:
Save it and lets build our first image. In this case, we are literally pulling and building an image as is.

build

The -t option is to give a tag to the image you just built. The first line sends the data to docker demon.  2nd line prints the step from Dockerfile it executed. 3rd line is a layer identifier (every step is executed as a layer and cached for reuse when you rebuild). Final line shows the image built with its image id.

Let's check what images do we have now:

You will notice a new image (2nd last) which we just created. Next step is to run it. And we run an image by initiating a  docker container.  Let's do that

run

So, the last word bash here along with option i and t makes the container interactive with bash open. Lets try to run some simple commands.
If you notice ls worked just fine as it's a base linux image. However, unzip did not. The reason? Well Oracle Linux 7 docker image that you pulled doesn't include that. Options? You have 2 options. First, you go ahead install in the container. Secondly, you can extend this original image and have instructions to install unzip and build an image.

Though both options will work but 2nd option helps you avoid installing manually every time you have a new container. And this becomes super productive when you need a complete development environment for multiple developers to build and test their work. For example, you can configure with some additional utilities and a node or have a docker container for hosting a db.

Assuming you are convinced with the requirement of having your own image, lets extend our image and rebuild. The modified Dockerfile will look like below:
And on building, and starting a new container and trying the same will look like below:
So, this time you have an enhanced image with unzip installed. Before we go ahead and push it to docker hub lets see how to see all the running containers and stop any if we want.

stop

So, that how we list and stop a container by its id. Lets now push the image to docker hub. For pushing there are 3 steps. 1 tag your image 2 login 3 push


That's it. Your new image is ready for you and World (if you like) to consume. To see how it appears on docker hub here is a screenshot:


Congratulations!!! Hope you find it useful.


Thursday, October 29, 2015

Oracle ADF Jdeveloper 12c Groovy Expression to Generate Sequence no longer works

Until Jdeveloper 12c for supplying primary key to your entity creation you could simply add a groovy expression in the primary key attribute's default expression like:

(new oracle.jbo.server.SequenceImpl("", adf.object.getDBTransaction())).getSequenceNumber()

However, running the same code in Jdeveloper 12 will throw following runtime exception:

General error during semantic analysis: JBO-25152: Calling the constructor for class oracle.jbo.server.SequenceImpl is not permitted.

Solution:

  • Open EO in the source view.
  • Search for trustMode="untrusted"
  • Change it to trustMode="trusted"
This should work now.

Tuesday, October 27, 2015

Installing Oracle XE on Virtual Box and Accessing it on Mac OS X Yosemite

Oracle XE  is not yet supported on Mac OS X and if you are planning to do any development and required a local DB then you are pretty much out of luck to install it.

Solution?  Install Virtual Box with linux or windows machine and run oracle XE on it. Access it locally from your host os Yosemite in this case. There are two major steps in this.

  1. Installing Virtual box, guest OS and Oracle XE
  2. Configuring it to access Oracle XE from the Mac Yosemite. 

Step 1


  1.  Download latest version of virtual box
  2. For the guest OS and DB either you can individual download the images and install all that or you can use one of the Oracle prebuilt images. They will be a bit larger in size due to some more stuff but will do the job as one step solution. I used Downloads and Instructions
  3. Once you have a everything installed and the image imported you will need to make sure that you can run your XE DB in the guest OS first. Do the following:
    1. from the Applications menu click on "Oracle XE DB --> Start Oracle Database". Wait for few min.
    2. From the same place click on "Run SQL lite terminal"
    3. In the terminal type  connect / sysdba  and this should connect if DB is up and running. 
    4. by default HR schema is installed and locked. So run the following 
      1. alter user hr account unlocked identified by hr
    5. This should do the job and will ensure that it all works fine.

Step 2

  1. Click on the top right corner and enable network on your guest OS (eth0 by default)
  2. Go to Virtual box and installed image settings. Click Network tab and click on Port Forwarding.
  3. Add a new entry here marking as: Host ip: 127.0.0.1 port 1522 guest ip: blank port: 1521 and do ok.
  4. This should now connect to the XE running in guest OS as  hr/hr@localhost:1522:XE (service name)
NOTE: The pre-built image I used in step 1 has the port 1521 unblocked by default. If you are manually doing the step 1 then you would need to unblock the 1521 port by guest OS firewall. You can do that following: http://www.thatjeffsmith.com/archive/2014/03/connecting-to-oracle-from-your-host-to-a-virtualbox-oel-guest/