Scroll Top

Docker: A New way to Deploy the Application

container security tools

Introduction:

In this post we will focus on understanding the containerization with Docker.

Containerization with Docker:

Deployment of an application is a tedious job. Only a single application need’s to be deployed on a single physical machine. Virtualization made its possible to deploy different applications on a single machine. Virtualization is one of the important concepts in a cloud. Each virtual machine has its own environment. Hyper-visor is used to implement hyper-visor level virtualization. But in this type of virtualization each VM requires its own resources like CPU , Memory, and Guest Operating Systems.

docker

Another concept is container level virtualization, aka. containerization. In container level virtualization, an OS kernel is used for creation of guest instances. Each guest instance consists of its own processes, memory, and file system. It’s like a VM, but not actually a VM. It’s a lightweight container which is running with file systems and necessary resources which is required by the application.

docker

Docker is a container level virtualization. It creates images of  applications and runs it on a physical server. Each running image is called a container.

Installation of docker: For other OS please find link here.


#!/bin/bash
#This is the installation script for the docker
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv — keyserver hkp://p80.pool.sks-keyservers.net:80 — recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo cat /etc/apt/sources.list.d/docker.list<<EOF
deb https://apt.dockerproject.org/repoubuntu-xenial main
EOF
sudo apt-get update
sudo apt-get purge lxc-docker
sudo apt-cache policy docker-engine
sudo apt-get update
sudo apt-get install linux-image-extra-$(uname -rsu)
sudo apt-get update
sudo apt-get install docker.io
sudo service docker start
sudo docker run hello-world

For other ubuntu version you can use:


#!/bin/bash
echo “Checking curl is installed or not…”
which curl
echo “If not installed…”
sudo apt-get install curl
echo “Update ubuntu…”
sudo apt-get update
echo “Installing the docker…”
sudo curl -fsSL https://get.docker.com/ | sh

Lets create a simple docker image :  Curl with Ubuntu 14.04 LTS

To do this, it requires a Docker file which consists set of instructions.

Docker file:


FROM ubuntu:14.04
RUN apt-get -y update && apt-get install -y curl

First line will search the ubuntu:14.04 image locally. If its not available, then it will download it from the official image of ubuntu. By default it downloads from docker hub. Second command updates ubuntu and also it will install curl.

To make an image of this docker file:


$ docker build -t docker/ubuntuimg:1.0 .

Don’t forgot the .(dot) at the end. Here docker is command and build is sub-command with option -t which allows you to create a docker image. Also, docker/ubuntuimg is the name of a repository of the image. 1.0 is a tag which shows the version of the image. If the version is not specified, the docker takes the latest as default.

Run the image:


$ docker run -it docker/ubuntuimg:1.0

Docker is the command and run is the subcommand. The -it instructs Docker to allocate a pseudo-TTY connected to the container’s stdin; creating an interactive bash shell in the container.

Check running images with:


$ docker ps

This is all about installing, creating a image, and running container with docker. Check our latest blogs here.

Related Posts

Leave a comment