Why Containerization ?
Up to now we have been working with monolithic applications where different components of service are packaged into a single application which is easy to develop, test and deploy.But when it becomes large and complex it’s become difficult as one team to work on it and the risk of failure is high at deploy time.
So to overcome, a new trend has been followed to work with microservices where components of the monolithic application are divided into small microservices. Here every microsevice will have its own API to handle its part of the application.
- It has advantages like each smaller service can use its own technology stack.
- The developers will find it easy to understand a single service.
- It’s also quicker to build and faster to deploy.
- The application becomes distributed and microservice scales quicker horizontally than vertical and becomes more fault tolerant.
Virtual Machines are too big to transfer and often too slow.
So containerization is the better choice when adopting Microservices architecture.
- Container is all about running an application and not just a VM
- Container is a virtualization method at operating system level, that allows running multiple instances of OS running in same kernel.
- Container is an image that contains apps, library, dependencies and most important kernel space components are provided by host operating systems
- NameSpace : Global system resources like network, PID, mount points are presented as such a way that container thinks this is only available to it
- CGroup : Used to reserve and allocate resources to container
- Union file system : Merge different file systems into one virtual file system.
Docker is one of the most popular container product, that is based on LXC and is an open platform to build , ship and run distributed applications.
– Docker Engine : portable, lightweight runtime packaging tool
– Docker Hub: A cloud service for sharing application
- Docker enables application to quick assemble from components
- It removes the friction between Dev,QA, Prod envs.
- The same app unchanged can run anywhere (lappy/PC/datacente).
Docker images are built from Dockerfile and the containers are built from images.
:: Setup ::
Installing Docker is easy. All the commands used here are in OEL6 in my workplace.
Update OS to atleast OEL6_UEK4 repo to use kernel > 4.1 (yum update and confirm kernel version, os > 6.4)
name=Latest Unbreakable Enterprise Kernel Release 4 for company Linux $releasever ($basearch)
yum update and reboot
> use docker repo:
2. Use btrfs filesystem:
yum install btrfs-progs
mkfs.btrfs /dev/sdb ( Add a raw disk and format with brtfs )
(FS tab entry )/dev/sdb /var/lib/docker btrfs defaults 0 0
3. Add proxy (if any to contact docker HUB)
/etc/sysconfig/docker ( If any ) OR add in /etc/default/docker( to use it with CURL)
4. Modify docker config
“$unshare” -m — $exec -d $other_args &>> $logfile &
$exec -d $other_args &>> $logfile &
5. Start docker service
# service docker start
# chkconfig docker on
6. Check docker details
service docker status
7. Add local user to docker group
usermod -a -G docker <local docker>
chmod g+rx /var/lob/docker
8. Search images in docker hub:(Before pulling check the availability)
docker search oraclelinux
docker searcg centos
docker searcg registry
9. pull oracle linux6.6 image:
docker pull oraclelinux:6.6
here oraclelinux – image is 6.6 – version
10. Check images:
11. Add this env variable for authenticity, integrity of images