Thursday 6 December 2018

Docker Installation on Windows Platform

Docker installation on Windows platform is straight forward, you need to download Docker setup executable and run it. Below are the steps to get docker working on Windows box.
 
Docker Installation on Windows:
1. Download stable docker image from: 
 
2. Run the executable and follow the wizard

3. Once done open command prompt

4. Type command "docker version" and you should see output like below for successful installation.
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:21:34 2018
 OS/Arch:           windows/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:29:02 2018
  OS/Arch:          linux/amd64
  Experimental:     false

Now you have done with Docker installation on Windows box.










Wednesday 14 February 2018

Docker on Amazon Ec2 Linux/CentOs

How to install and run Docker on Amazon Ec2 Linux/CentOs

DOCKER: Build, Ship & Run Your Software Anywhere, A lightweight tool which uses container to package up an application with all the requirements and dependencies before shipping the complete container as one package.  Docker is an application that makes it simple and easy to run application processes in a container, which are like virtual machines, which are more portable, more resource-friendly, and more dependent on the host operating system. For a detailed introduction to the different components of a Docker container please visit below link.
https://www.digitalocean.com/community/tutorials/the-docker-ecosystem-an-introduction-to-common-components

Features:
• Use Docker container with any language
• Ship the container wherever you want, be it QA, your team or even the cloud
• Scale up to 1000’s node
• Update with zero downtime

Best practice:
Step 1: Know your Linux release: In my case "4.9.77-31.58.amzn1.x86_64"
  • uname -r
Step 2: Check the update available and you can update a package if required update
  • sudo yum check-update
  • sudo yum update package_name
Step 3: Install Docker:
  • sudo yum -y install docker docker-registry
  • sudo service docker start
  • sudo chkconfig docker on
  • sudo service docker status
Step 4: Verify docker version and know more about docker system.
  • sudo docker --version
  • sudo docker info
Step 5: Add user to docker group to avoid typing sudo every time before docker commands
  • sudo usermod -aG docker $(whoami) (for logged in user)
  • sudo usermod -aG docker username (for any user)
Step 6: Download an image from docker hub(hello-world is known image at docker hub)
  • sudo docker run hello-world
Step 7: Search an docker image in docker hub repository.
  • sudo docker search centos
Step 8: Pull docker image from repository.
  • sudo docker pull centos
Step 9: List all downloaded images.
  • sudo docker images
Step 10: Run docker image.
  • sudo docker run centos
Step 11: Login to docker:.
  • sudo docker attach "docker-id"
[root@c0755c7130fc /]#

Other useful commands:
To view all containers — active and inactive, pass it the -a switch:
  • docker ps -a
To view the latest container you created, pass it the -l switch:
  • docker ps -l
Stopping a running or active container is as simple as typing:
  • docker stop container-id
Starting a stopped container is as simple as typing:
  • docker start container-id















Monday 5 February 2018

Ansible on Ubuntu 16.04


Ansible on Ubuntu:
Ansible is an automation engine, similar to Chef or Puppet, that can be used to ensure deployment and configuration consistency across many Servers/Network Gears, Ansible helps to keep servers and applications up-to-date. Ansible model is client less and works on SSH protocol to communicate and configure a client, Ansible takes on a modular approach, making it easy to extend to use the functionalities of the main system to deal with specific scenarios. Modules can be written in any language and communicate in standard JSON. Configuration files are mainly written in the YAML data serialization format due to its expressive nature and its similarity to popular markup languages. Ansible can interact with clients through either command line tools or through its configuration scripts called Playbooks.

How to install Ansible on Ubuntu 16.04
Step1: The best way to get Ansible for Ubuntu is to add the project's PPA (personal package archive) to your system, Add the Ansible PPA by using following command:
  • sudo apt-add-repository ppa:ansible/ansible

Step2: Now refresh system's package index so that it is aware of the packages available in the PPA and then install ansible
  • sudo apt-get update
  • sudo apt-get install ansible

Step 3: Configuring Ansible Hosts
Ansible keeps track of all of the servers through a "hosts" file. We need to set up this file first before we can begin to communicate with our other computers.
  • sudo vim /etc/ansible/hosts

Step4: Verification of ansible install:
  • ansible --version
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.6 (default, Nov 23 2017, 15:49:48) [GCC 4.8.4]

Other configuration files:
/etc/ansible/ansible.cfg
 /etc/ansible/playbooks/
/etc/ansible/roles/


Command Examples:
  • ansible "host_name" -i hosts -m command -a "uptime"
  • ansible -m shell -a "hostname" all
  • ansible-playbook "playbook_name" --ask-sudo-pass

Playbook to create group, user and install htop on ubuntu: Note apache is the name in config file under which I have defined servers on which configuration needs to be done.
***********************************************************************************
---
- hosts: apache
  sudo: yes
  tasks:
  - name: install htop package
  apt: name=htop update_cache=yes state=latest

  - name: creating groups
  group: name=test-group state=present

  - name: creating user
  user: name=devops uid=2001

**********************************************************************************















Wednesday 31 January 2018

Jenkins on Amazon Linux(EC2 Instance)/CentOS



Jenkins on Amazon Linux(EC2 Instance)/CentOS

I have written a useful blog in very simple and understandable way to install the jenkins on Amazon Linux(EC2 Instance)/CentOS, below are the steps and command that need to install and run jenkins on above Linux flavor.

Step 1: Best practice to update Linux before installing the application but it is optional.
  • sudo yum install epel-release
  • sudo yum update
  • sudo reboot

Step 2: Install Java 8 and make it in operation, if java 7 is there then jenkins would not work, java8 needs to be installed and java 7 need to be removed.
  • sudo yum install -y java-1.8.0-openjdk.x86_64
  • sudo /usr/sbin/alternatives --set java /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
  • sudo /usr/sbin/alternatives --set javac /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/javac
  • sudo yum remove java-1.7

Step 3: Set the Environment for JVM.
  • sudo cp /etc/profile /etc/profile_backup
  • echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
  • echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
  • source /etc/profile

Step 4: Verify Java version and Java environment.
  • java -version
  • echo $JAVA_HOME
  • echo $JRE_HOME

Step 5: Install Jenkins on Amazon Linux/CentOS
  • cd ~
  • sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
  • sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
  • yum install jenkins
  • sudo service  jenkins enable
  • sudo service  jenkins start
  • sudo service  jenkins status

Step 6: Run your Jenkins via web browser.
  • http://server_ip:8080

Step 7: Unlock jenkins by supplying password created during installation, To find the password "sudo cat  /var/lib/jenkins/secrets/initialAdminPassword"


Step 8: Now all the steps done, just click on install suggested plugins to get started.


Now you have done the job, I want to give some more additional useful details here.

Command to run jenkins on different port rather than default: java -jar jenkins.war --httpPort=8081
Home directory for jenkins on Amazon Linux/Centos: /usr/lib/jenkins
Config file: /etc/sysconfig/jenkins
                 /var/lib/jenkins/
jenkins user config file path: /var/lib/jenkins/users/user_name