Thursday, December 29, 2016

Install Shipyard to monitor Docker Containers

So far I have a number of containers on my ubuntu box , looked at the easiest way to manage them all and gave shipyard a try .

There are 2 ways to install shipyard both involve (without any surprise) to make use of docker containers.

I have tried the manual install as it gives me more flexibility . The link to the installation is found here . This comes as a number of docker images to run .

The key thing to bear in mind is that wherever you see <IP-OF-HOST> you need to add the actual public ip address of the docker host .

Below are some examples of where the swarm manager and agent ask for the <IP_OF_HOST>

docker run \ -ti \ -d \ --restart=always \ --name shipyard-swarm-manager \ swarm:latest \  manage --host tcp:// etcd://<IP-OF-HOST>:4001

docker run \ -ti \ -d \ --restart=always \ --name shipyard-swarm-agent \ swarm:latest \  join --addr <ip-of-host>:2375 etcd://<ip-of-host>:4001

Do not put localhost as this IP address else you will not be able to view containers on the docker host .

Also you can configure the port on which your shipyard WEB GUI is accessible by changing the port number below highlighted in yelow i.e 7777

docker run \ -ti \ -d \ --restart=always \ --name shipyard-controller \ --link shipyard-rethinkdb:rethinkdb \ --link shipyard-swarm-manager:swarm \ -p 7777:8080 \ shipyard/shipyard:latest \ server \ -d tcp://swarm:3375

Tuesday, December 27, 2016

Oracle 12c setup using Docker on Ubuntu

Recently had to install Oracle 12c on an ubuntu 16.04 server  , the quickest way I found to do that was through docker .


First things first we need to setup docker and this is done by following the docker docs :

Installing Oracle Image 

Now that you have a working docker install you need to :

  1. Download the image for Oracle 12c 
  2. Open port 8080 and 1541 such as you get access to the web Application express interface and are able to connect to the Oracle instance via SQLPlus respectively
  3. Map a source directory on your docker host with a directory within the Docker Oracle container should you want to import dumps for example
All the above can be achieved within the command below :
docker run -d -P --name atlas_oracle12 -p 8080:8080 -p 1521:1521  -v /home/ubuntu/atlaslocaldump:/u01/app/oracle/admin/xe/dpdump/ sath89/oracle-12c  

Things to note are that :
  1. atlas_oracle12 - this is the name I have given to my container , it can be any valid name e.g foo 
  2. /home/ubuntu/atlaslocaldump - this directory on my docker host which i want to make visible within the oracle docker container ( so basically the source )
  3. /u01/app/oracle/admin/xe/dpdump/ - this is the directory on the docker container from which i will be able to access the files within /home/ubuntu/atlaslocaldump 
  4. sath89/oracle-12c - this is the name of the image for the Oracle-12c install , you can get more information around this here on docker hub  .
  5. Also it takes around 10-15 mins depending on your machine to initialise the Oracle instance so you might not just be able connect straight to SQLPlus .. give it some time to initialise

So once the DB is up and running you might want to access the Oracle instance via SQLPlus , to do that you can either install SQLPlus on your docker host and connect or you go within your Oracle container and access the bash , I have done the later as installation of SQLPlus client on Ubuntu was a completely nightmare .

So connect to the oracle container using the following command :
docker exec -it atlas_oracle12 bash 

 Note that atlas_oracle12  is the name of the container that you defined in the docker run command above if this is not the name of the container then change it to reflect your own container name.

Now that we are within the container SQLPlus can be called using :
$ORACLE_HOME/bin/sqlplus system/oracle@//localhost:1521/

Importing a Dump

You can also import a dump using the following command :

$ORACLE_HOME/bin/impdp USERNAME/PASSWORD@//localhost:1521/ dumpfile=myDumpFile.dmp  logfile=myLogFile.log table_exists_action=replace schemas=mySchema 
Do change the values above to correspond to your specific settings

Removing the  Oracle Container

For some reasons you might want to remove the oracle container in our case it is named atlas_oracle12 ( change this below to the name you gave your container instance )

To do that you need to stop the contained using command :

docker stop atlas_oracle12

Then remove the container directly using :

docker rm atlas_oracle12

You can check that the container is removed by doing a :

docker ps