Tuesday 12 January 2016

Start Oracle Dataguard Training with the most simple Dockerfile

Refers to our Docker-Dataguard-Project

After a long absence I feel obliged to bring this project to an end. Therefore I start my works with the most simple Dockerfile

Click on the picture to enlarge
See Dockerfile Reference for the instructions in a Dockerfile and best practices. For the sake of simplicity I have set WORKDIR and VOLUME to an absolute path, which is never a goog style. In future posts, I will enhance that and explain a bit deeper the meaning of WORKDIR and VOLUME, Note the instruction RUN:  if you are not familiar with the groupadd / useradd - commands,  look them up in the man pages or in tutorials, they are trivial. What you need to know for Oracle databases is, that the user oracle must belong to the indicated groups.

Click to enlarge
A little explication of the build command: there is a docker daemon which belongs to root and is called by /usr/bin/docker -d > docker.session 2>&1 & -  see my post upstart-try-using.html

And there is a docker client, which you simply call typing "docker --help" e.g. for getting help. Try it out. For the details see the extensive documentation Docker userguide

The client  command docker build sends the instructions of the Dockerfile to the docker daemon. The most simple build command is what you see here: docker build -t oraclelinux:demo . 
NOTE the last argument: it is a dot, the symbol for the actual working directory. I will explain that deeper in the next posts.

The result of a successfull build process is a new image which contains the existing image plus the changes made during the build. It seems a bit magic, but simply reflects, that before the build I have downloaded an official docker image called oraclelinux:7.1 from an official docker repository, where 7.1 after the colon is called a tag, which refers to the "release", and afterwards I have another image called oraclelinux:demo.  Use the command docker images to see them.

Click to enlarge
Let's come back to  photo above which shows the steps of the build process. Step 0 - 4 are simply echoing the instructions. What happens here in intermediate containers will be described in a later post. Important here is step 5: we need the unzip tool to install the Oracle software and we need a user oracle with two roles, hence 2 groups oinstall  and dba. I come back to that in future posts.

So we rely on the image oraclelinux:7.1 to come along with the tedious preconditions required for Oracle databases. See my post about required packages . You can control - inside oraclelinux:7.1 of course - the installed packages with the Linux utility rpm like that e.g.

[root@97607feb304d myscripts]# rpm -qa | grep libgcc          
libgcc-4.8.3-9.el7.x86_64


There is one thing we must control before the installation of Oracle database software: we are bound to work as the user oracle, hence we need the unix command su - oracle (substitute user identity in this user's environment). We start an new container with the command docker run [options][arguments]

Click to enlarge

The option -it starts an interactive Pseudo-Terminal.
The option --rm removes the new container at the session end.
The argument oraclelinux:demo runs the just newly created image in the container.
The argument /bin/bash runs a bash process as the user root.

We convince ourselves that the unzip - tool is installed, that the user oracle exists and is member of the correct groups and that we really are able to run su - oracle. Everything seems fine.

In future sessions we will just run a container with the last argument like that:

Click to enlarge
To be continued soon.


1 comment:

Anonymous said...

This Dockerfile is too simple and I am convinced, that oraclelinux:7.1 does not come along with all packages required for a full installation of Oracle 12c Enterprise Edition.

The pictures serve to show the result of an operation, but when you present an operation itself, I want to copy & paste your text. Please publish scripts etc. as plain text