Showing posts with label docker-compose. Show all posts
Showing posts with label docker-compose. Show all posts

Saturday, May 5, 2018

3. Learning How to build Best Docker images?

The containerization concept was available since the 1978s in the UNIX. but the real usage and evaluation started from the year 2014 onward, a small community of docker open-source organizations started to focus on it and developing it.

In the last post, we had the unofficial image then it went up the size up to 3.8 GB. But same logic if we try on Oracle Linux 7-Slim version image it reduced 1 GB!!!

  Use Layered approach for Oracle images  

Most of the developers question how do we deliver it to end-user when you create the containers for WebLogic. The best practice to use the layered approach for WebLogic applications. We have demonstrated with the following layer approach the whole stack is going to break down into two major parts:

  1. Read-only 
  2. Read-write 
The latest image is on top which is only allows you to modify the content. where application jar/war/ear file will be deployed.
The bottom stack will be re-used by multiple developers to build their container and work with no-time spending that's the beauty of this containerization technology.


Please refer to the Oracle White paper.
WebLogic docker image layers


Recently we had a requirement to develop the containers of Oracle SOA. if we take the old stack it is not flexible enough to support the requirements. Always prefer to use the latest installers, Oracle SOA 12c is flexible for supporting Containerization.

Use the yum -y clean

When you install any of the dependent libraries that used for WebLogic or database or SOA software in the container. These libraries first pulled from the repo to a buffer, then installation process happen. Better to clean this junk after installation completed.

Preferable option to use official images
When you search for any image then you will be finding many images which are publicly available. Out of the images list there could be official select that one, which is more reliable than others.

Use Dockerfile to build images

Remember that in Dockerfile every instruction line is going to create a container. Each container will be stored in the docker engine just similar to the SVN repository that have id. To build docker image by writing single RUN command with slash for separating commands for multiple commands to execute on the temporary container.

Use docker-compose instead of lengthy docker run

using docker-compose you will be saving time to write lengthy docker run commands. If you store the run command into composing file you will have more advantages you can build the docker image and also run the image as a container in a single go. You can modify the ports and other values to create more containers.

Multi-purpose of docker-compose commands

Please follow my YouTube Channel. Write your experiences/queries with the docker and docker-compose in the below give comment box. We are happy to help you in containerizing your environments.


References

Oracle WebLogic Server on Docker Containers

Thursday, January 18, 2018

The docker-compose for Oracle 12c XE

Oracle Database 12.1.0.2 Express Edition



After a while got time to explore the new learning in my way. Oracle 12.1.0.2 Express edition on docker container is my goal. In this post I am going to explain you how did I achieved this with different path of using docker-compose commands to bringing up the automated XE container. The regular choice is defined in GitHub and Docker hub it was mentioned to use docker pull and docker run commands to use.

Advantages of containerizing Oracle 12c XE

  • No need to download any software from OTN
  • No need to install - dockerfile will take care of it
  • No need to run dbca for Database cration - executed moment container boot time
  • No need to start LISTENER, STARTUP database because this container choosen is AUTOMATED [OK]


Lets search for the Oracle 12c XE

docker search oracle12c

Output of docker search result
Docker Oracle 12c XE search

The docker-compose for Oracle 12c XE Database


oracle12cxe:
 image: rodrigozc/oracle12c
 ports:
  - "1521:1521"
  - "8089:8080"
  - "2222:22"


docker-compose config
networks: {}
services:
  oracle12cxe:
    image: rodrigozc/oracle12c
    network_mode: bridge
    ports:
    - 1521:1521
    - 8089:8080
    - '2222:22'
version: '2.0'
volumes: {}

docker-compose up -d
Creating oraclexe_oracle12cxe_1

Now lets check the docker-compose wit running process list
 docker-compose ps
         Name                Command       State                                  Ports
-----------------------------------------------------------------------------------------------------------------------
oraclexe_oracle12cxe_1   /entrypoint.sh    Up      0.0.0.0:1521->1521/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8089->8080/tcp

SSH Connection with port 2222


Using PuTTY terminal you can connect to the container that is running Oracle 12c XE database in it.

Oracle 12.2.0.1 XE docker container SSH connection

check logs what is happening in the container when it was just started...

vagrant@docking ~/oracle_xe $ docker-compose logs oracle12cxe
Attaching to oraclexe_oracle12cxe_1
oracle12cxe_1  | SSH server started. ;)
oracle12cxe_1  | ls: cannot access /u01/app/oracle/oradata: No such file or directory
oracle12cxe_1  | Database not initialized. Initializing database.
oracle12cxe_1  | Starting tnslsnr
oracle12cxe_1  | Copying database files
oracle12cxe_1  | 1% complete
oracle12cxe_1  | 3% complete
oracle12cxe_1  | 11% complete
oracle12cxe_1  | 18% complete
oracle12cxe_1  | 37% complete
oracle12cxe_1  | Creating and starting Oracle instance
oracle12cxe_1  | 40% complete
oracle12cxe_1  | 45% complete
oracle12cxe_1  | 50% complete
oracle12cxe_1  | 55% complete
oracle12cxe_1  | 56% complete
oracle12cxe_1  | 60% complete
oracle12cxe_1  | 62% complete
oracle12cxe_1  | Completing Database Creation
oracle12cxe_1  | 66% complete
oracle12cxe_1  | 70% complete
oracle12cxe_1  | 73% complete
oracle12cxe_1  | 85% complete
oracle12cxe_1  | 96% complete
oracle12cxe_1  | 100% complete
oracle12cxe_1  | Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/xe/xe.log" for further details.
oracle12cxe_1  | Configuring Apex console

Here the log file shows that installation successful. And Now lets check the Expression Edition Enterprise manager console

http://192.168.33.100:8089/em

Oracle Enterprise Manager database express 12c Login page
Please enter the the login credentials as: sys/oracle select the check box as sysdba option. Because we want to do a DBA task now create user.

After login successful you will get the SYSDBA access.

Create User on Oracle 12c EM Console
Create User account as demouser 

Tablespaces for demouser

Assign privileges RESOURCE, CONNECT to demouser

Create User SQL statement processed succesfully


In the PuTTY terminal connect with oracle/welcome1 ssh credentials.
export ORACLE_HOME=/u01/app/oracle/product/12.1.0/xe
export PATH=$ORACLE_HOME/bin:$PATH

To check Oracle Database running with process that have pmon word:
 ps -ef|grep pmon
You can check for the Oracle database configured and the Listener started with entrypoint.sh script.
lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 04-SEP-2017 19:16:36

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                04-SEP-2017 18:33:10
Uptime                    0 days 0 hr. 43 min. 26 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/diag/tnslsnr/38a4e2e216dd/listener/ale     rt/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=38a4e2e216dd)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=38a4e2e216dd)(PORT=8080))(Presentati     on=HTTP)(Session=RAW))
Services Summary...
Service "xe.oracle.docker" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
Service "xeXDB.oracle.docker" has 1 instance(s).
  Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully

Confirm the User creation

Using SQL*Plus you can test the connection to the demouser that created in the above section.

 sqlplus demouser/welcome1@localhost:1521/"xe.oracle.docker"

Output looks like this:


connection validation using SQL*Plus

You can also define your own SID and use that for creating RCU and move further.

Please share your feedback on this experiment how it helps you and any suggestions to improve more posts on containerization in Oracle DevOps.

References:

Git Hub link for Oracle 12c+ SSH 
Docker hub link of Rodrigozc

Saturday, July 15, 2017

5. docker-compose for WebLogic cluster deployment

In the earlier post you have seen how to use docker-compose for WebLogic images to build and also run the container with new application deployment. In this post you will be able to see the WebLogic managed servers forms cluster and the application will be deployed on top of it.

Prerequisites

Let me keep the list of prerequisite steps which you can follow my previous blog post or youtube video.

  1.  docker pull oraclelinux:7-slim  
  2. git clone https://github.com/oracle/docker-images.git 
  3. download server-jre1.8 latest version copy to OracleJava/dockerfiles build the image and make it as oracle/serverjre:8
  4. download weblogic 12.2.1.2.0 quick installer which is used for development, it is small in size. image name it as oracle/weblogic:12.2.1.2-developer 
  5.  create new docker images where 12212-domain:latest using WLST and shell script which are available in container scripts. 
  6. create new docker images named as 1221-appdeploy:latest where it uses 12212-domain as base images. 
  7. And also docker pull httpd:2.4 6. download the proxy plugin for 12.2.1.2 create the 1221-webtier:latest [apache with proxy plugin configured]

The power of docker-compose script

Now lets pick the following docker-compose.yml file where it will use two images the two images : 1221-appdeploy, 1221-webtier Using last session created admin container for create managedserver with port change
version: '2'

networks:
  &network wlsnet:
    driver: bridge

services:

  # Deploys the wlsServer with default hostname 'wlsadmin' used by scripts in 1221-domain.
  &adm adminserver:
    image: &i 1221-appdeploy
    container_name: wlsadmin
    ports:
    - "8001:7001"
    networks:
      - *network

  # Deploys a container running a Managed Server and a Node Manager to control MS from wlsServer
  managedserver:
    image: *i
    command: createServer.sh
    networks:
      - *network
    depends_on:
      - *adm

  # Deploys a container running only a node manager. to deploy a managed server here later, use wlsServer Web Console
  nodemanager:
    image: *i
    command: createMachine.sh
    networks:
      - *network
    depends_on:
      - *adm

 # WebTier for load balancing requests to cluster
  webtier:
    image: 1221-webtier
    networks:
      - *network
    ports:
    - "8800:80"
    environment:
      - WEBLOGIC_CLUSTER="managedserver:7001"
    links:
      - managedserver

################ END OF compose file ###############################

Next steps

8. Validate the docker configuration syntax docker-compose config
9. If all good then proceed for the run the containers - wlsadmin, managedserver, nodemanager and webtier docker-compose up
10.  Check the containers logs with container names as argument docker-compose ps docker logs wlscluster_managedserver_1 -f
 11. Expansion of docker containers for clustered Weblogic domain. docker-compose scale managedserver=4


We will be more happy to help you for your dockerization of WebLogic environments.

References:


Blurb about this blog

Blurb about this blog

Essential Middleware Administration takes in-depth look at the fundamental relationship between Middleware and Operating Environment such as Solaris or Linux, HP-UX. Scope of this blog is associated with beginner or an experienced Middleware Team members, Middleware developer, Middleware Architects, you will be able to apply any of these automation scripts which are takeaways, because they are generalized it is like ready to use. Most of the experimented scripts are implemented in production environments.
You have any ideas for Contributing to a Middleware Admin? mail to me wlatechtrainer@gmail.com
QK7QN6U9ZST6