Monthly Archives: November 2017

5. DevOps: How to work with Docker Images

Docker-logo

In  continuation of my previous blog on “4. DevOps: How to work with Docker Containers”, in this blog I would like to give some lab practice on Docker Images.

How to pull the docker public images ?:
Docker portal will have numerous images available  under public.
Now, there is a need for us to know the usage of docker pull command, which is the defacto command to download Docker images.

Now, in this section, we will use the busybox image, one of the smallest but a very handy Docker image, to dive deep into Docker image handling:
$sudo docker pull busybox
============= Output ============>
vskumar@ubuntu:/var/tmp$ sudo docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
0ffadd58f2a6: Pull complete
Digest: sha256:bbc3a03235220b170ba48a157dd097dd1379299370e1ed99ce976df0355d24f0
Status: Downloaded newer image for busybox:latest
vskumar@ubuntu:/var/tmp$
=================>
Sometimes it might reject this request. We need to keep on trying to get it. I tried 4 times at different timings to connect to it.
Please note now, we have three images as below through all of our so far exercises:
===================>
vskumar@ubuntu:/var/log$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest f2a91732366c 4 days ago 1.85kB
ubuntu latest 20c44cd7596f 7 days ago 123MB
busybox latest 6ad733544a63 3 weeks ago 1.13MB
vskumar@ubuntu:/var/log$
===============>
Now, let us stop the docker services and check the status as below:
=================>
vskumar@ubuntu:/var/log$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest f2a91732366c 4 days ago 1.85kB
ubuntu latest 20c44cd7596f 7 days ago 123MB
busybox latest 6ad733544a63 3 weeks ago 1.13MB
vskumar@ubuntu:/var/log$ sudo service docker stop
vskumar@ubuntu:/var/log$ sudo service docker status
● docker.service – Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
Active: inactive (dead) since Sat 2017-11-25 02:52:25 PST; 8s ago
Docs: https://docs.docker.com
Process: 1224 ExecStart=/usr/bin/dockerd -H fd:// (code=exited, status=0/SUCCE
Main PID: 1224 (code=exited, status=0/SUCCESS)
Nov 25 02:21:42 ubuntu dockerd[1224]: time=”2017-11-25T02:21:42.863518710-08:00″
Nov 25 02:21:43 ubuntu dockerd[1224]: time=”2017-11-25T02:21:43-08:00″ level=inf
Nov 25 02:27:08 ubuntu dockerd[1224]: time=”2017-11-25T02:27:08.010096274-08:00″
Nov 25 02:27:08 ubuntu dockerd[1224]: time=”2017-11-25T02:27:08-08:00″ level=inf
Nov 25 02:27:08 ubuntu dockerd[1224]: time=”2017-11-25T02:27:08.199685599-08:00″
Nov 25 02:52:25 ubuntu dockerd[1224]: time=”2017-11-25T02:52:25.010875880-08:00″
Nov 25 02:52:25 ubuntu systemd[1]: Stopping Docker Application Container Engine.
Nov 25 02:52:25 ubuntu dockerd[1224]: time=”2017-11-25T02:52:25.081714537-08:00″
Nov 25 02:52:25 ubuntu systemd[1]: Stopped Docker Application Container Engine.
Nov 25 02:52:25 ubuntu systemd[1]: Stopped Docker Application Container Engine.
vskumar@ubuntu:/var/log$
====================>
You can see the inactive status of docker.
In such cases, restart the Docker service, as shown here:

$ sudo service docker restart
You can see the output as below:
==================>
vskumar@ubuntu:/var/log$ sudo service docker restart
vskumar@ubuntu:/var/log$ sudo service docker status 
docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: e
   Active: active (running) since Sat 2017-11-25 02:54:42 PST; 6s ago
     Docs: https://docs.docker.com
 Main PID: 3769 (dockerd)
    Tasks: 18
   Memory: 24.6M
      CPU: 989ms
   CGroup: /system.slice/docker.service
           ├─3769 /usr/bin/dockerd -H fd://
           └─3778 docker-containerd --config /var/run/docker/containerd/containe

Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.159062708-08:00"
Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.159806997-08:00"
Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.163503112-08:00"
Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.743276580-08:00"
Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.955217284-08:00"
Nov 25 02:54:41 ubuntu dockerd[3769]: time="2017-11-25T02:54:41.975961283-08:00"
Nov 25 02:54:42 ubuntu dockerd[3769]: time="2017-11-25T02:54:42.092220161-08:00"
Nov 25 02:54:42 ubuntu dockerd[3769]: time="2017-11-25T02:54:42.094334663-08:00"
Nov 25 02:54:42 ubuntu systemd[1]: Started Docker Application Container Engine.
Nov 25 02:54:42 ubuntu dockerd[3769]: time="2017-11-25T02:54:42.190194886-08:00"

vskumar@ubuntu:/var/log$ 

========================>

Now, let us reconfirm the existing docker images as below:
================>

vskumar@ubuntu:/var/log$ ^C
vskumar@ubuntu:/var/log$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              f2a91732366c        4 days ago          1.85kB
ubuntu              latest              20c44cd7596f        7 days ago          123MB
busybox             latest              6ad733544a63        3 weeks ago         1.13MB
vskumar@ubuntu:/var/log$ 
=======================>

By default, Docker always uses the image that is tagged as latest.

Each image variant can be directly identified by qualifying it with an appropriate tag.

An image can be tag-qualified by adding a colon (:) between the tag and the repository name (<repository>:<tag>). For demonstration, we will pull the 1.24 tagged version of busybox as shown here:

Now, For lab demonstration, we will pull the 1.24 tagged version of busybox as shown here:

$ sudo docker pull busybox:1.24

Now. You can see the total output before and after executing the above command:

==============================>

vskumar@ubuntu:/var/log$ ^C

vskumar@ubuntu:/var/log$ sudo docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

hello-world latest f2a91732366c 4 days ago 1.85kB

ubuntu latest 20c44cd7596f 7 days ago 123MB

busybox latest 6ad733544a63 3 weeks ago 1.13MB

vskumar@ubuntu:/var/log$ ^C

vskumar@ubuntu:/var/log$

vskumar@ubuntu:/var/log$

vskumar@ubuntu:/var/log$ sudo docker pull busybox:1.24

1.24: Pulling from library/busybox

385e281300cc: Pull complete

a3ed95caeb02: Pull complete

Digest: sha256:8ea3273d79b47a8b6d018be398c17590a4b5ec604515f416c5b797db9dde3ad8

Status: Downloaded newer image for busybox:1.24

vskumar@ubuntu:/var/log$ sudo docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

hello-world latest f2a91732366c 4 days ago 1.85kB

ubuntu latest 20c44cd7596f 7 days ago 123MB

busybox latest 6ad733544a63 3 weeks ago 1.13MB

busybox 1.24 47bcc53f74dc 20 months ago 1.11MB

vskumar@ubuntu:/var/log$

==============================>

There are two busybox containers with different versions.

So, on the basis of TAG values the containers are being pulled.

How to Search Docker images:

So far we have pulled the known images from the docker-hub.

Let us identify some docker images by using a search option as below. We can search for Docker images in the Docker Hub Registry using the docker search subcommand, as shown in this example:

$ sudo docker search mysql

You can see the displayed output of mysql images from the Docker Hub Registry:

=============>

vskumar@ubuntu:/var/log$ sudo docker search mysql

NAME DESCRIPTION STARS OFFICIAL AUTOMATED

mysql MySQL is a widely used, open-source relation… 5278 [OK]

mariadb MariaDB is a community-developed fork of MyS… 1634 [OK]

mysql/mysql-server Optimized MySQL Server Docker images. Create… 368 [OK]

percona Percona Server is a fork of the MySQL relati… 303 [OK]

hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 74

zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 64 [OK]

centurylink/mysql Image containing mysql. Optimized to be link… 53 [OK]

sameersbn/mysql 48 [OK]

zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 38 [OK]

tutum/mysql Base docker image to run a MySQL database se… 29

1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 17 [OK]

schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 16 [OK]

centos/mysql-57-centos7 MySQL 5.7 SQL database server 15

linuxserver/mysql A Mysql container, brought to you by LinuxSe… 12

centos/mysql-56-centos7 MySQL 5.6 SQL database server 6

openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6

frodenas/mysql A Docker Image for MySQL 3 [OK]

dsteinkopf/backup-all-mysql backup all DBs in a mysql server 3 [OK]

circleci/mysql MySQL is a widely used, open-source relation… 2

cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release 0

cloudposse/mysql Improved `mysql` service with support for `m… 0 [OK]

ansibleplaybookbundle/rhscl-mysql-apb An APB which deploys RHSCL MySQL 0 [OK]

astronomerio/mysql-sink MySQL sink 0 [OK]

inferlink/landmark-mysql landmark-mysql 0 [OK]

astronomerio/mysql-source MySQL source 0 [OK]

vskumar@ubuntu:/var/log$ ^C

vskumar@ubuntu:/var/log$

====================>

You can get the top 5 images by suing head -5 linux command.

$sudo docker search mysql | head -5

=============>

vskumar@ubuntu:/var/log$ sudo docker search mysql | head -5

NAME DESCRIPTION STARS OFFICIAL AUTOMATED

mysql MySQL is a widely used, open-source relation… 5278 [OK]

mariadb MariaDB is a community-developed fork of MyS… 1634 [OK]

mysql/mysql-server Optimized MySQL Server Docker images. Create… 368 [OK]

percona Percona Server is a fork of the MySQL relati… 303 [OK]

vskumar@ubuntu:/var/log$

===============>

If you see the above list, The mysql image curated and hosted by Docker Inc has a 5278 star rating, which is indicated as this is the most popular mysql image and aslo as Official image to use it. For security reasons we should use the official and highly rated images only.

As we planned, in this blog we have worked with the Docker images.

At this point we can stop this session and in the next blog we can see on “How to work with interactive containers”.

Feel free to Contact me :Vcard-Shanthi Kumar V-v3

 

 

 

3. DevOps – Jenkins[2.9]: How to create and build the job ?

jenkins

In continuation of my previous blog on Jenkins 2.9 installation [https://vskumar.blog/2017/11/25/1-devops-jenkins2-9-installation-with-java-9-on-windows-10], We have installed and retested it. In this blog we can see a simple job creation and running it in a build.

Now, Let us do some exercise:

Let us create a new job using Jenkins.

As you are aware of; with Jenkins any kind of manual tasks can be done.

For example:

  1. I want to compile a java program and run it.
  2. To do this 1st let us identify the manual steps.
  3. I need to go to the below directory: D:\JavaSamples\Javatest , where my java programs are available.
  4. I need to use the below command:

CD [to know the current directory.]

Assume, I am in the below dir:

D:\Jenkins\jenkins-2.90>cd

D:\Jenkins\jenkins-2.90

Then , I need to use cd \JavaSamples\Javatest

Now I need to check my current path using cd

Then see the hello*.java using

dir command.

Then I need to compile it using ‘javac HellowWorld.java’ command.

Then I need to check the files on hello*.* name

There should be one file as ‘HellowWorld.class’

It means my program has been compiled correctly without errors.

Now, I need to run the program using java command.

Now, I need to run this file as java HellowWorld

It should display the output.

I have executed all the steps in a command window to compile and test the program.

You can see the executed commands and the  output also from the below screen:

HelloWorld-compile&amp;execute-CMD

As we know these are the manual tasks we need to do repetetively to select a program, compile it and run it. Why don’t we use Jenkins to create a job which has these set of tasks.

Now, let us learn how to create a job in Jenkins?:

Now assuming you are on the below screen:

Jenkins-New Job Creation

Click on “create new jobs”

You will get the below screen:

Jenkins job creation-enter an item name scrn.png

I want to create a job with the name of “vskumar2017test1”.

Jenkins-Freestyle project-creation

I want to create a Freestyle project, as I do not work with any of the plugins for now.
Hence I need to select on the 1st option “ Freestyle project”. When I click on “OK” button, we can see the below screen:

Jenkins-Freestyle project-creation2

I have entered the project description as below, as per our activity plan:

Jenkins-Freestyle project-description

As you are aware we are using Jenkins for simple task in this exercise,

Now click on build options. You will get the below screen:

Jenkins-Freestyle project-Build.png

In this screen we need to use build option. So click on add build steps. Using this option, we will get the below features to use the command window and the commands:

Jenkins-Freestyle project-Build-Add build step

There are two different options we can see to use the commands execution. 1. Execute Windows batch command , 2. Execute shell. Currently e are working with windows only. Hence 1st option need to be selected.

You can see the below screen:

Jenkins-New Job-Build-window commands1

Now, whatever commands we tried using command prompt we need to enter those.

For example I used as below:

cd

cd \JavaSamples\Javatest

dir hellow*.java

javac HellowWorld.java

dir HellowWorld.*

java HellowWorld

Now, I am copying these commands into the window. You can see the partially displayed commands in the window. In reality it has all the commands.

Jenkins-Build-Windows-batch commands-entry1

Now, let us save this job.
We will get the below screen on the created job name:

Jenkins-Project-vskumar2017test1.png

How to run the created project ?:

We need to run the created project using the option “Build now”.

You can see the build history as the job running, Under build#1.

Now, How to see the executed job output ?:
To see the output we need to click on the down arrow mark ate the job#.
It displays the below:

We need to select the console output, It displays the output as below:

Jenkins-Project-vskumar2017test1-running-build1-consoleOuputIf we scroll down we can see the job status message:

Jenkins-Project-vskumar2017test1-running-build1-consoleOuput

It shows all the output for our commands along with the job status.

Now let us review and analyze the display messages and commands as below.

Started by user Vskumar2017
Building in workspace D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1
[vskumar2017test1] $ cmd /c call C:\WINDOWS\TEMP\jenkins5234154176626743505.bat

The above commands shows, Jenkins started the job with user id vskumar2017.N

And it displays the current path of the job where it is created.

And it invokes a .bat file to execute the command prompt commands what we entered. It means it stored the batch commands into a file and it is opened by a cmd command from a shell prompt.

Now, let us see the below commands:

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd
D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1

It denotes its current job/project directory. And executed the cd to show the path.

Through the below:

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd  \JavaSamples\Javatest 

D:\JavaSamples\Javatest>dir hellow*.java 
 Volume in drive D is New Volume
 Volume Serial Number is 5C67-6F04

 Directory of D:\JavaSamples\Javatest

04/16/2017  03:52 PM               234 HellowWorld.java
04/16/2017  03:53 PM               570 HellowWorld10.java
               2 File(s)            804 bytes
               0 Dir(s)  22,762,598,400 bytes free

It changed the directory where the java program is there.

And displayed the files.

Let us see the next output:

D:\JavaSamples\Javatest>javac HellowWorld.java 
'javac' is not recognized as an internal or external command,
operable program or batch file.

It shows error for java path. Jenkins is not recognizing the path. The javac [compiler application is in the below path: D:\Java\jdk-9.0.1\bin ]

Javac-path.png

Now, this need to be corrected in the project.
To correct this we need to goto option: “Configure”.

Open it into project window to update some more commands.

I have updated the command window with the below commands:
cd \JavaSamples\Javatest
dir hellow*.java
del HellowWorld.class
dir hellow*.java
D:\Java\jdk-9.0.1\bin\javac HellowWorld.java
dir HellowWorld.*
java HellowWorld

Now, let me run the job by using “Build now option”.

For debugging purpose, I have executed this job some more times. Hence history shows multiple builds on it.

Our current build is #5. And let us open it and see the console output:

Jenkins-Project-vskumar2017test1-buildsNow#5

The console output shows as below:

Jenkins-Project-vskumar2017test1-console#5

Now you can see the whole console output as below in text format:

Console Output
Started by user Vskumar2017
Building in workspace D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1
[vskumar2017test1] $ cmd /c call C:\WINDOWS\TEMP\jenkins1398066858541735603.bat

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd
D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd \JavaSamples\Javatest

D:\JavaSamples\Javatest>dir hellow*.java
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

04/16/2017 03:52 PM 234 HellowWorld.java
04/16/2017 03:53 PM 570 HellowWorld10.java
2 File(s) 804 bytes
0 Dir(s) 22,761,955,328 bytes free

D:\JavaSamples\Javatest>del HellowWorld.class

D:\JavaSamples\Javatest>dir hellow*.java
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

04/16/2017 03:52 PM 234 HellowWorld.java
04/16/2017 03:53 PM 570 HellowWorld10.java
2 File(s) 804 bytes
0 Dir(s) 22,761,955,328 bytes free

D:\JavaSamples\Javatest>D:\Java\jdk-9.0.1\bin\javac HellowWorld.java

D:\JavaSamples\Javatest>dir HellowWorld.*
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

11/17/2017 12:3

9 PM 427 HellowWorld.class
04/16/2017 03:52 PM 234 HellowWorld.java
2 File(s) 661 bytes
0 Dir(s) 22,761,955,328 bytes free

D:\JavaSamples\Javatest>java HellowWorld
Hello World

D:\JavaSamples\Javatest>exit 0
Finished: SUCCESS

=======================>
Observe there was no error displayed as we have given the correct javac application path.

Now I have updated the commands as below to remove the existing HellowWorld.class file.
cd
cd \JavaSamples\Javatest
dir hellow*.*
echo ‘Assuming .class file is already there..”
del HellowWorld.class
dir hellow*.java
D:\Java\jdk-9.0.1\bin\javac HellowWorld.java
dir HellowWorld.*
java HellowWorld
=======================>
You can see the output under build#7:
========================>

Console Output
Started by user Vskumar2017
Building in workspace D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1
[vskumar2017test1] $ cmd /c call C:\WINDOWS\TEMP\jenkins7100481173282587024.bat

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd
D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1

D:\Jenkins\Jenkins 2.9\workspace\vskumar2017test1>cd \JavaSamples\Javatest

D:\JavaSamples\Javatest>dir hellow*.*
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

11/17/2017 12:45 PM 427 HellowWorld.class
04/16/2017 03:52 PM 234 HellowWorld.java
04/16/2017 03:53 PM 570 HellowWorld10.java
3 File(s) 1,231 bytes
0 Dir(s) 22,760,976,384 bytes free

D:\JavaSamples\Javatest>echo ‘Assuming .class file is already there..”
‘Assuming .class file is already there..”

D:\JavaSamples\Javatest>del HellowWorld.class

D:\JavaSamples\Javatest>dir hellow*.java
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

04/16/2017 03:52 PM 234 HellowWorld.java
04/16/2017 03:53 PM 570 HellowWorld10.java
2 File(s) 804 bytes
0 Dir(s) 22,760,976,384 bytes free

D:\JavaSamples\Javatest>D:\Java\jdk-9.0.1\bin\javac HellowWorld.java

D:\JavaSamples\Javatest>dir HellowWorld.*
Volume in drive D is New Volume
Volume Serial Number is 5C67-6F04

Directory of D:\JavaSamples\Javatest

11/17/2017 12:47 PM 427 HellowWorld.class
04/16/2017 03:52 PM 234 HellowWorld.java
2 File(s) 661 bytes
0 Dir(s) 22,760,976,384 bytes free

D:\JavaSamples\Javatest>java HellowWorld
Hello World

D:\JavaSamples\Javatest>exit 0
Finished: SUCCESS
=================================>
Now, you can see message display from echo command.
And the old class file is removed and the new file time stamp can be seen differently.

Now, how to make failure a job ?:

Please see the screen display with a failed job:

Jenkins-vskumar2017-success1

Now, let us see the console output:

Console-output-vskumar2017-3.png

In this example I have given a wrong file name to execute. Hence it is failed.
It checks the last commands results. You can change them and cross check as an exercise.
The failure error flag also it shows as “1”.
When the job was success the flag showed as “0”.

Hope you understand the difference between failure and success of Jenkins build.
So, we need to make sure the commands/script mentioned in the command window should be a debugged one. Then the jobs success can be seen.

Please note;
If it is not a recognized command as an internal or external command,
operable program or batch file. Jenkins will not count it as a failure.

Exercise:
Take a new Java program and create a job to compile and run it.

How to use My views:
You can see the build history in graphical format as below with My views option:

Jenkins-Job-Views

 

At this point with this blog I want to close now, with the above scenarios.

You can also see:

https://www.youtube.com/edit?o=U&video_id=lciTHyxCgfE

 

Feel free to contact for any support:

Vcard-Shanthi Kumar V-v3

2. DevOps: How to install Docker 17.03.0 community edition and start working with it on Ubuntu 16.x VM

Docker-logo.png

In this blog, I would like to demonstrate the Docker 17.03.0  CE edition installation on Ubuntu 16.0.4 VM machine. And later on little practice can be shown  using containers in a series of blogs. Please keep visiting for weekly new blogs or subscribe it. If you are interested to follow this site blogs, please send e-mail [with your linkedin message ] to approve with authentication.

Assume you have an unbuntu machine or a Virtual machine [VM] configured. And in this blog you can see on how to install the Docker 17.03.0  CE [as on this blog’s date] with screen display outputs:

$ sudo service docker restart

However, if the Active column shows inactive or maintenance as the status, your Docker service is not running. In such cases, restart the Docker service, as shown here:

$ sudo service docker restart 
 
Install Docker on Unbuntu:

1.Add the Docker package repository path for Ubuntu 16.04 to your APT sources, as shown below:
 $ sudo sh -c "echo deb https://apt.dockerproject.org/repo \
 ubuntu-xenial main > /etc/apt/sources.list.d/docker.list"

2.Add the GNU Privacy Guard (GPG) key by  running the following command:
 $ sudo apt-key adv --keyserver \
 hkp://p80.pool.sks-keyservers.net:80 --recv-keys \ 
 
3.Resynchronize with the package repository using the below command:
 $ sudo apt-get update
Now docker software is in your unbuntu machine.

4. Now, you can Install Docker and start  Docker service:
 $ sudo apt-get install -y docker-engine

5.Now you have  installed the Docker Engine, we need to  verify our installation by running docker --version as shown below:
 $ docker --version

We have successfully installed Docker version 17.03.0 community edition.
Other options is; in a single script by avoiding the above steps you can install it:

If you are working on Ubuntu, follow the below command:

==================== Screen output ==========>
vskumar@ubuntu:/var/log$ sudo wget -qO- https://get.docker.io/ | sh |more
[sudo] password for vskumar: 
# Executing docker install script, commit: 11aa13e
Warning: the "docker" command appears to already exist on this system.
If you already have  installed Docker, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.
If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.
You may press Ctrl+C now to abort this script.
+ sleep 20
+ sudo -E sh -c apt-get update -qq >/dev/null
============== Since I have already installed, I have breaked this process ====>
But, if you try this script; it takes some time to download and install docker for the whole process. 
Be patient to see the final result.  Later check the docker version to reconfirm. Using the below command.
$docker --version

It is very easy to install docker with the above step(s) in your Ubuntu machine.

Assuming you have studied the theory part of docker usage I am moving forward to lab practice.

Now, let us do some practice with docker images/containers.

We will do the below steps:

1. Downloading the first Docker image:
we will download a sample hello-world docker image using the following command:
$ sudo docker pull hello-world

2. Once the image is downloaded, 
they can be verified using the docker images subcommand, as given below:
To check the image run the below command:
$sudo docker run hello-world
It displays the message “Hello from Docker!”
You have set up your first Docker container and it is running now.

3. How to Troubleshoot with Docker containers?:
If you want to troubleshoot with container, the first step is  to check the Docker's running status by using the below command:
$ sudo service docker status 
It displays the status and shows as Docker 'Active running' message on the screen along with other messages.
Press ctrl+C to come out from the display.

=========== Partial content from the above command =====>
vskumar@ubuntu:/var/log$ sudo service docker status 
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2017-11-25 02:54:42 PST; 3h 56min ago
Docs: https://docs.docker.com
Main PID: 3769 (dockerd)
Tasks: 19
Memory: 43.6M
CPU: 1min 21.184s
CGroup: /system.slice/docker.service
├─3769 /usr/bin/dockerd -H fd://
└─3778 docker-containerd --config /var/run/docker/containerd/containerd.toml
===============================>
For some reasons, if the Active column shows inactive or maintenance as the status, it means your Docker service is not running. 
In that case to restart the Docker service, use the below command:

$ sudo service docker restart

We will see in the next blog, some more exercises on Docker containers and images.

Vcard-Shanthi Kumar V-v3

 

 

 

 

 

 

 

 

 

 

1. DevOps – Jenkins[2.9] Installation with Java 9 on Windows 10

 

 

 

 

 

 

 

jenkins

I am publishing  series of blogs on DevOps tools  practice. The interested people can keep watching this site or you can subscribe/follow.

In this blog we will see what are the pre-requisites for Jenkins 2.9 to install and how to install Jenkins.

To setup Jenkins, you need to have Java 9 in your local machine.

Hence in the Step1 to setup Java, you need to follow the below steps:

STEP1: How to download and install JDK SE Development kit 9.0.1 ?:

go to URL:

http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html

You will see the below page [as on today’s display]

Java Kit SE 9 download

From this web page, Click on Windows file jdk-9.0.1_windows-x64_bin

It will download.

Double click on the file.

You will see the series of screens, while it is doing installation. I have copied some of them here.Java SE 9 install scrn-2.png

Java SE 9 install scrn-1

Java SE 9 install scrn-3.png

 

Java SE 9 install scrn-4.png

You can change the directory if you want, in the above screen.

 

Java SE 9 install scrn-4-Oracle 3 billion.png

 

Finally you should get the below screen as installed it successfully.

Java SE 9 install scrn-5-complete

Now, you need to set the Java environment and path variable in Windows setting.

Java SE 9 install scrn-7-windows env setup2Java SE 9 install scrn-8-windows env setup3

 

My Java directory path is:

Java SE 9 install scrn-9-windows env setup4

 

Java SE 9 install scrn-10-windows env setup5.png

You  need to edit the below path variables also for the latest path:

Java SE 9 install scrn-11-windows env setup6Java SE 9 install scrn-12-windows env setup7.png

After you have done the settings, you can check the java version as below in a command prompt:

Java SE 9 install scrn-13-CMD-1

You should get the same version.

Now, You need a simple java program to run and check your compiler and runtime environment.

Please goto google search and check for “Java Hello wordl program”.

Follow the below URL:
https://en.wikiversity.org/wiki/Java_Tutorial/Hello_World!

Copy the program into a text file named as hellowworld.java

Then compile and run the program as below:

Java SE 9 install scrn-14-CMD-Javacompile&run-1.png

If you are getting the above, then your installed java software is working fine.

You need to remember the below:
To compile this program you need to use the below command in command prompt of that program directory:

D:\JavaSamples\Javatest>javac HellowWorld.java

To run the java program you need to use the below command:

D:\JavaSamples\Javatest>java HellowWorld
Hello World

Now, you can plan for setting up Jenkins.

STEP2: How to setup Jenkins on Windows ?:

Follow the below link to download Jenkins for Windows-x64
https://jenkins.io/download/thank-you-downloading-windows-installer/

It downloads the installer as below:
You can see the downloaded installer file for Jenkins.

Jenkins-installer-file1.png

 

How to install Jenkins?:
Now you can copy this file into a new directory as Jenkins.

I have copied into the below directory.

Jenkins-installer-file-copy1.png

You need to unzip this file.

Jenkins-installer-file-unzip1.png

You can see the new directory is created with its unzipped files:

 

Jenkins-installer-file-unziped-new Dir

You can double click on it and can see the below screen:

 

Jenkins-installer-file-double-click.png

I have changed the path as below:

Jenkins-installer-file-path.png

Click on install and say “Yes” in windows confirmation screen.

 

Jenkins-installer-file-path-install.png

You can see the below screen:

Jenkins-installer-install-complete1.png

Once you click on finish, it will take you to a browser:

Jenkins-initial browser1.png

Jenkins will have a default user id as “admin” and the password.
The password is available from the given path.

Jenkins-admin-initial-pwd-file

You can open this file in notepad as below:

Jenkins-admin-initial-pwd-file-open-notepad

Now, copy this password as below into windows clipboard.

Now you goto the Jenkins browser and paste this password.

Close your notepad.

Now, on browser press continue.

You can see the Jenkins initial  screen as below for plugins selection:

 

Jenkins-initial screen for plugins

Jenkins will have 100s of plugins. But there are default plugins those can be used initially to save you disk space and time. Hence now, you click on “Install suggested plugins”.

It will show the below screen as it is working for this activity:

Jenkins-default-plugins-install-screen1.png

You can see in the right side window the tasks what Jenkins is doing:Jenkins-initial screen for plugins-tasks1.png

You can also watch as it is doing one by one the plugins installation and the tasks on right side.
It might take more than 30 mts depends on your internet speed and the RAM.

I am copying some of the screens as it is moving on …

 

Jenkins-initial screen for plugins-tasks2.png

Once the plugins are installed, you can see the 1st screen to setup your 1st admin user id and password as below:

Jenkins-create-first-UID &amp; PWD

You can enter the details and click on “Save and Finish” button.

Now, it shows the below screen with Jenkins readyness to use:

Jenkins-is-Ready.png

When you click on “Start using Jenkins” button,
You can see the below screen as in the beginning of the Jenkins usage:

Jenkins-welcome-1st time.png

Please observe the right corner and verify your created user id.

Now, let us do some login and logout operations to make sure it is working.

When you logout you can see the below screen:

Jenkins-initial-logout-test

Now let us understand the url of Jenkins server which we are using:

When we install Jenkins in any machine either Windows or Linux.
By default its url should be : http://localhost:8080/
Your local host is your current machine Ip address.
You can see the screen now with the above url:

Jenkins-URL-test

Now, you can try one more option, check your ip address from command prompt as below:

Check-IPs-CMD.png

You can pickup the 1st IP address which displays from the command prompt screen.

And key-inn the below url in your browser:
http://192.168.137.1:8080/login?from=%2F

Your ip need to be used in place of 192.168.137.1

Now, let us see What is 8080?:
Every server software creates a port address to access its web pages from the installed machine. In our case Jenkins has been configured on 8080 port as default. The 8080 is a default port for Jenkins. Similarly other server softwares also will have their specific ports.

Now, I have used a different browser using the above url to access Jenkins web page as below:

Jenkins-using-IP & 8080-Port.png

Using the login screen I am logging into my admin user id: vskumar2017 , which was created earlier.

Login-UID-vskumar2017.png

You can also check in your windows services on Jenkins running status.
Please note on this setup, you have made a standalone Jenkins by using your PC or Laptop.

Now, you can restart your windows machine. You need to start Jenkins as fresh service.

To start Jenkins from command line
  1. Open command prompt.
  2. Go to the directory where your war file is placed and run the following command: java -jar jenkins.war
  3. OR One more  option is; go to your Jenkins directory in CMD window and execute: jenkins.exe start

 

Restart-Jenkins-CMD

Open browser and Use you can check the Jenkins access. It should be showing the login page.

How to remove Jenkins from your system?:

If you want to remove Jenkins from your system, you can find the  Jenkins Windows installer file from the Jenkins directory and double click on it. You can see the below window to choose your action:

Remove-repair-Jenkins.png

So far we have seen the installation of Java 9 and Jenkins.

Some times, you might need to configure other servers [Ex:Tomcat, etc,]. They might also use 8080 port. Hence there will be conflict. We need to change the port# in that case.

Now, How to change your 8080 port to other port#?:

Please find Jenkins.xml in Jenkins dir:

Ex:

In my system I have the URL:D:\Jenkins\Jenkins 2.9

You need to replace 8080 with the  required port# in the below line:

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar “%BASE%\jenkins.war” –httpPort=8080 –webroot=”%BASE%\war”</arguments>

In the next blog we can see some simple exercise with Jenkins by creating and running the project into different builds.

https://vskumar.blog/2017/11/26/2-devops-jenkins2-9-how-to-create-and-build-the-job/

 

https://vskumar.blog/2018/02/26/15-devops-how-to-setup-jenkins-2-9-on-ubuntu-16-04-with-jdk8/

Note to the reader/user of this blog:

If you are not a student of my class, and looking for it please contact me by mail with your LinkedIn identity. And send a connection request with a message on your need. You can use the below contacts. Please note; I teach globally.

Vcard-Shanthi Kumar V-v3

If you want to learn for Ubuntu installation you can visit:

https://vskumar.blog/2018/02/26/15-devops-how-to-setup-jenkins-2-9-on-ubuntu-16-04-with-jdk8/

Advt-course3rd page