top of page
Writer's pictureSiddhesh Kadam

Why Docker ??



Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, thanks to the container, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.


In a way, Docker is a bit like a virtual machine. But unlike a virtual machine, rather than creating a whole virtual operating system, Docker allows applications to use the same Linux kernel as the system that they're running on and only requires applications be shipped with things not already running on the host computer. This gives a significant performance boost and reduces the size of the application.



So lets begin with installation of Docker on Centos


Installation Of Docker


[root@tecgeek ~]# yum install docker


After installation start the Docker service


[root@tecgeek ~]# systemctl start docker


Enable Docker service to be start during server reboot


[root@tecgeek ~]# systemctl enable docker


Download Docker Images From Docker Hub


Docker Hub is a cloud-based repository in which Docker users and partners create, test, store and distribute container images. Through Docker Hub, a user can access public, open source image repositories, as well as use a space to create their own private repositories, automated build functions, webhooks and work groups.



In free subscription you can create single private repository and single parallel build.


For more plan visit @ https://hub.docker.com/pricing


So l have singed up for free subscription to pull images from docker hub.


If you try pull any image from docker hub without signing in then you may get below error of un-authorisation


[root@tecgeek ~]# docker pull centos Using default tag: latest Trying to pull repository docker.io/library/centos ... Get https://registry-1.docker.io/v2/library/centos/manifests/latest: unauthorized: incorrect username or password

[root@tecgeek ~]#


Here

pull : Pull an image or a repository from a registry

centos : Name of Image to search in repository


Lets try to sign in into docker hub and see what difference it makes


[root@tecgeek ~]# docker login --username=siddheshtechtalk

Password:

Login Succeeded

[root@tecgeek ~]#


Here

--username : supplies username for authentication under repository

siddheshtechtalk : is username of docker hub


[root@tecgeek ~]# docker pull centos

Using default tag: latest

Trying to pull repository docker.io/library/centos ...

latest: Pulling from docker.io/library/centos

8ba884070f61: Pull complete

Digest: sha256:a799dd8a2ded4a83484bbae769d97655392b3f86533ceb7dd96bbac929809f3c

Status: Downloaded newer image for docker.io/centos:latest

[root@tecgeek ~]#


Similarly you can run hello-world image which is only built for testing your integrity with Docker Hub


[root@tecgeek ~]# docker run hello-world


Hello from Docker!

This message shows that your installation appears to be working correctly.


To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the "hello-world" image from the Docker Hub.

(amd64)

3. The Docker daemon created a new container from that image which runs the

executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it

to your terminal.


To try something more ambitious, you can run an Ubuntu container with:

$ docker run -it ubuntu bash


Share images, automate workflows, and more with a free Docker ID:

https://hub.docker.com/


For more examples and ideas, visit:

https://docs.docker.com/get-started/

[root@tecgeek ~]#


So now we have successfully downloaded centos docker image from hub and test integretiry by running hello-world test image.


To see downloaded imaged on local system run below command


[root@tecgeek ~]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

docker.io/centos latest 9f38484d220f 4 months ago 202 MB

docker.io/hello-world latest 4ab4c602aa5e 10 months ago 1.84 kB

[root@tecgeek ~]#


Here


docker.io/centos : Image/size details which we downloaded from Docker Hub

docker.io/hello-world : Test image which we ran to verify Docker Setup


Search For Available Images On Docker Hub


[root@tecgeek ~]# docker search centos

INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED

docker.io docker.io/centos The official build of CentOS. 5461 [OK]

docker.io docker.io/ansible/centos7-ansible Ansible on Centos7 122 [OK]

docker.io docker.io/jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.6.1810 x... 110 [OK]

docker.io docker.io/consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 93 [OK]

docker.io docker.io/centos/mysql-57-centos7 MySQL 5.7 SQL database server 59

docker.io docker.io/imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 57 [OK]

docker.io docker.io/tutum/centos Simple CentOS docker image with SSH access 44

docker.io docker.io/centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relationa... 38

docker.io docker.io/kinogmt/centos-ssh CentOS with SSH 28 [OK]

docker.io docker.io/pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag nam... 10

docker.io docker.io/nathonfowlie/centos-jre Latest CentOS image with the JRE pre-insta... 8 [OK]

docker.io docker.io/drecom/centos-ruby centos ruby 6 [OK]

docker.io docker.io/darksheer/centos Base Centos Image -- Updated hourly 3 [OK]

docker.io docker.io/mamohr/centos-java Oracle Java 8 Docker image based on Centos 7 3 [OK]

docker.io docker.io/pivotaldata/centos Base centos, freshened up a little with a ... 3

docker.io docker.io/miko2u/centos6 CentOS6 日本語環境 2 [OK]

docker.io docker.io/pivotaldata/centos-gcc-toolchain CentOS with a toolchain, but unaffiliated ... 2

docker.io docker.io/pivotaldata/centos-mingw Using the mingw toolchain to cross-compile... 2

docker.io docker.io/blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK]

docker.io docker.io/indigo/centos-maven Vanilla CentOS 7 with Oracle Java Developm... 1 [OK]

docker.io docker.io/mcnaughton/centos-base centos base image 1 [OK]

docker.io docker.io/fortinj66/centos7-s2i-nodejs based off of ryanj/centos7-s2i-nodejs. Bi... 0

docker.io docker.io/pivotaldata/centos6.8-dev CentosOS 6.8 image for GPDB development 0

docker.io docker.io/pivotaldata/centos7-dev CentosOS 7 image for GPDB development 0

docker.io docker.io/smartentry/centos centos with smartentry 0 [OK]

[root@tecgeek ~]#


Please Visit Docker Reference Guide For More Details...


Run Docker Container


Lets try to run our first container Centos which we downloaded from Docker Hub


[root@tecgeek ~]# docker run -it centos

[root@b0d031a98f7b /]# cat etc/hostname

b0d031a98f7b [root@b0d031a98f7b /]# exit

[root@tecgeek ~]#


Here


docker run : Run a command in a new container

-it : give interactive shell access into container

b0d031a98f7b : container id of image, which gets set as a hostname.




 


Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page