DOCKER

 ////////////////////////////////////////////////////////////////////////////////////////////////////

tecmint install docker centos

https://www.tecmint.com/install-docker-on-ubuntu/

https://www.tecmint.com/install-docker-and-learn-containers-in-centos-rhel-7-6/

https://www.tecmint.com/build-and-configure-docker-container-images-with-dockerfile/

https://www.tecmint.com/install-run-and-delete-applications-inside-docker-containers/

https://www.tecmint.com/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps/


 ////////////////////////////////////////////////////////////////////////////////////////////////////

https://www.tecmint.com/linux-commands-cheat-sheet/

 ////////////////////////////////////////////////////////////////////////////////////////////////////

hub.docker.com

https://hub.docker.com/u/rohit17jan/content/sub-40286dac-8330-48ef-bc07-2e0041ed3f78

 ////////////////////////////////////////////////////////////////////////////////////////////////////

======================================

        How to install Docker

======================================

1. write 

docker -version

 

    this will give command to install docker 

    i got below mentioned command

    apt  install docker.io

2. Become part of swarm.

    we can become member of swarm using mentioned command.

        swarm init

3. Create Registry

    we can create registry service using mentioned command.

        docker service create --name registry --publish published=5000,target=5000 registry:2

4. Install JRE8 

    1. we need to configure the Docker file for that. Content of docker file is mentioned below

        FROM store/oracle/serverjre:8

        WORKDIR /usr/java/default/lib/security

        COPY ./local_policy.jar   .

        COPY ./US_export_policy.jar .

        COPY ./filebeat-6.2.2-linux-x86_64 /opt/

        WORKDIR /home

    2. We can not download directly oracle jre. We need to create account docker hub. We can use mentioned url for that https://hub.docker.com/

    3. After that write docker login and press enter. This is a one time process.

    4. Execute following command. wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.2.2-linux-x86_64.tar.gz

    5. then execute tar -xf filebeat-6.2.2-linux-x86_64.tar.gz

    6. Now build the image using mentioned command docker build --no-cache -t jre8 . (dot is included)

    7. After successful image build, We need to tag the image to registry using mentioned command. docker tag jre8  127.0.0.1:5000/jre8:latest

    8. After push the image to registry using mentioned command. docker push 127.0.0.1:5000/jre8:latest

 

5. Configure Individual Service.

    1. Make Docker File for individual service.Docker File should contains following things.

        FROM 127.0.0.1:5000/jre8

 

        EXPOSE 5000

 

        RUN mkdir -p /var/workspace

 

        WORKDIR /var/workspace

 

        COPY . .

 

        ENV TZ=Asia/Kolkata

 

        RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

 

        ENTRYPOINT ["java", "-jar", "-Xms128m", "-Xmx512m", "-Dspring.config.location=./application.properties", "otp-service.jar"]


    2. The Folder should contains all the file example jar file,properties file and Docker file.

    3. Now build the image using mentioned command docker build --no-cache -t <servicename> . (dot is included)

    4. After successful image build, We need to tag the image to registry using mentioned command. docker tag <servicename> 127.0.0.1:5000/<servicename>:latest

    5. After push the image to registry using mentioned command. docker push 127.0.0.1:5000/<servicename>:latest

    6. We need to create a stack file. Stack file normally we need to keep under /var/docker/. Stack file should contain something like mentioned.

        version: '3.3'

        serices:

            otpservice:

                image: 127.0.0.1:5000/<servicename>:latest 

                ports:

                 - "7004:5000"

                deploy:

                 mode: replicated

                 replicas: 1

                volumes:

                 - "rp:/var/workspace/logs"

        volumes:

            rp:


    7. Then Deloy the stack using mentioned command. docker stack deploy -c stackfile.yml <stackname>

 ////////////////////////////////////////////////////////////////////////////////////////////////////


docker pull store/oracle/serverjre:1.8.0_241-b07



# docker login

Username: <Docker Hub/Store Username>

Password: <Docker Hub/Store Password>

Login successful.



docker pull store/oracle/serverjre:8


  "image":"ghghgh"

 ////////////////////////////////////////////////////////////////////////////////////////////////////

https://linuxdady.com/what-is-docker-container/

 ////////////////////////////////////////////////////////////////////////////////////////////////////

What is docker container and it’s terminology

I think every DevOps engineer will be familiar with docker word. Docker container technology is increasing day by day. So, it become must for us we should learn docker. In this article we are going to learn about docker container, and it’s use case like where docker is fit or where it is not fit.

Also, we will learn basic term of docker that is very useful to understand the functionality of docker container. But before moving to docker container we should first aware machine provisioning.

What is machine provisioning?

Machine provisioning means to build or ready new server for development, testing or another teams that is working in our company. Before docker we were doing provisioning with the help of VM, Xen, ESXI etc. The drawback of using these technology as compare to docker container is —>

  • Time consuming because build a new machine every time then hardening, and doing application setup this process is time consuming.
  • Use more manpower
  • High costing because using more manpower and waste of their time for doing provisioning.
  • Taking VM machine more startup and shutdown time 
  • More hardware consumption because we have to set new VM for every application.

I hope now machine provisioning world properly set in your mind. So, now time to move towards docker.

What is docker container?

In single line I will explain what is docker containerDocker is a community which bring concept of containers-based virtualization. For better understanding you can say docker is a company and container is kind of virtualization where our application will run.

Why companies are moving on docker?

There are lot of reason to move VM technology to Docker container technology. I have discussed some of my favorite reason in below diagram. If you have any other comment me in comment box.

VMware vs Docker

When we should move for docker container?

When we are running N number of applications then we should think to move towards docker container technology. If we are running only 2-3 application, then no need to move docker. Because when we are using N number of technology then there will be changes of port confliction, libraries confliction. We have to think about cost optimization, use of manpower, hardware consumption etc.

Docker Architecture

By a single diagram you will understand the docker container concept.

What is docker

[Click & Read:–  How to configure AWS autoscaling in production]

In this diagram we have tried to explain suppose you want to set docker container infra then you have to take hardware –> Install your desired OS –> Install docker package –> launch container. But in case of VM you need a hypervisor like VMware, xen etc. that will install on your hardware then install again guest OS for every VM. So, to launch new VM for every application is waste of hardware as well waste of time and cost.

Docker workflow 

Before learning any technology we should learn first workflow of that technology means how that technology works? In this diagram we have explained docker workflow.

First we will install docker package on our OS then will launch container –>Finialy launch our application into container.

What is docker

[Click & Read:–  How to configure aws application load balancer]

Where docker is fit ?

Up to here  you have well understood what is docker and its use cases. Now we will discuss Where docker is fit or where it is not fit.

  • In case of docker container monitoring tool are not fit because these tools need complete control of our OS but docker not have compete control of our base OS.
  • Still docker container have some lacking point for big production environment. It doesn’t mean we cannot use docker in production. We can use in production environment but depend on need.
  • Docker is best suitable for continuous deployment and testing environment.

Some useful term for docker container

Now we are going to discuss some basic term that is very important. We should learn that to understand docker in deep. Let’s try to understand.

Docker host 

Docker host is a VM or dedicated hardware where we have installed our docker rpm package. That machine might be Linux, Windows, Mac depends on our requirements.

Docker image 

For better understanding you can say docker image is an ISO image that have minimal packages. Means you can say it has those binaries, libraries file and pre-installed software like java, python etc. that is mandatory to run our application. Docker image is light weight as usual image. There are lot of community that is providing trusted open source and paid image like Docker hub, Redhat etc. 

Docker image registry server

You can say docker registry server is a centralized point or location where we put our desired image for future use. We can pull, push our image when required.

Container 

Container is running mode of our docker image means when we launched our image that It becomes container. Into that container we can run our application.

Docker hub

Docker hub is docker community registry portal from where we can download our image. They designs image and put at docker hub we can pull and push images here. There are two type of images

  • License based
  • Open source

Docker client

This is also very important term because basically this term create confusion. You can say docker client is our docker administrator that can manage our docker from another host instead of docker dedicated host.

I think you are now well known what is docker container and its advantage. Let’s have a look again advantage of docker.

  • It helps to optimize our infra cost
  • It helps to reduces manpower
  • It helps to save time
  • Boot up, start up, shutdown time is small as compare to VM
  • No tension of libraries confliction
  • No tension of port confliction
  • We can run multiple application on a single VM with the help of docker.
  • No tension of performance. Performance is like our base machine.

Conclusion

Docker container technology is best for testing and development team. Because development and testing team need is changing continuously. In such kind of situation docker container is fully fit. So, in this tutorial we have learnt what is docker container? Basic terminology regarding docker that we should aware before learning docker. If still you have any query write comment box. I will try my best to resolve them.

Docker interview question ?

If you want to stay in IT world keep sharing knowledge and continue study. So keep ans. below question answer in comment box. Right or wrong does’t meter. At least try–>

1) why we put image on registry server?

2) How we will identify image is trusted or not

3) How we will identify image is open source or licensed

4) Can we increase performance by using docker container.

5) Can container replace VM. If yes, then why? If not, then why?

6) Difference between docker host and  docker engine?

 ////////////////////////////////////////////////////////////////////////////////////////////////////

/////////////////////////////

https://linuxdady.com/docker-network-configuration/

/////////////////////////////

Understand docker network configuration concept

Docker network configuration concept is very important for every docker engineer. Because without complete knowledge of docker network we cannot manage containers properly. So, in this tutorial we are going to learn how to configure docker network and what are the type of docker network?

Docker network configuration

Before moving forward first we have to take a look of theoretical part of docker network type. Basically, docker using two type of network: –>

  • Bridge network
  • Host network

Bridge Network

If you want to separate IP over every container or you want to run multiple containers using the same port on docker host then there is no option except bridge network means with help of bridge network we can isolate our container with different different IP address. All these containers connected to physical network card (NIC) via bridge network. We have to do only port forwarding to pass traffic from docker host to container via bridge network. For better understanding go through diagram.

container bridge architecture

Host Network

Let’s take a scenario to understand host network suppose you want to run a webserver container via using host network. So, when container will launch it will use IP address and port number of base machines means our webserver will run into container but using base host IP and port number. So, remember one thing your 80 port is reserved for webserver in future we cannot launch more container of webserver because they will use port 80 but port 80 is already in use. So, using host network is not best approach but it’s depends on requirement.

docker host architecture

[Click & Read:–  How to mount external volume with container ]

[Click & Read:–  How to create docker image manually and from dockerfile]

Now we are going to launch a container and check which one IP address is container getting from default pool.

launch container

We will find that it is providing IP address from its default pool. After installing net-tools package run ifconfig command to check IP address.

check container IP

Docker network configuration list we can check by below command. This command will show all available docker network type. 

check docker network

In above figure we have checked here bridge and host default network are showing . Now let’s add new bridge adapter manually. Prod is name of bridge network that we are going to add and 192.168.10.0/24 is my subnet. In your case change name and subnet accordingly.

docker network configuration

We have successfully added bridge network with name prod of subnet rang 192.168.10.0/24. Now we  will launch a container into this subnet. New upcoming container will use IP address from this subnet.

Execute ifconfig command and check which one IP is showing. IP address should be from new subnet like 192.168.10.2. It is providing IP address that is free into bridge pool.

docker network configuration

We are going to set manually IP address at our upcoming container.  

check IP of container

Put a container more than one network means we can attach multiple adapter with a container.

docker network configuration

Check how many adapters are attached with con2.

docker network configuration

We can attach and detach network of container on the fly. To change IP address from Ethernet configuration file manually is not best practice.

or if you want to delete prod bridge network permanently then execute below command.

Host Network

As discussed already docker network is used when we need to run single service on single port means it will use network of base machine. Let’s have a look

host network

Conclusion

In this tutorial we have covered docker networking part which is very important of every docker engineers. Because without docker network configuration you cannot manage container properly. So , still if anyone have query regarding docker network write in comment box. I will try my best to resolve them.

 Interview question from docker network configuration

  1. When we launch a container which one IP is assigned by default statics or dynamic?
  2. Can we change container IP on the fly means in ruining state?
  3. Can we attach a container more then one bridge network?
  4. What are the difference between host network and bridge network?
  5. When I want to run multiple container of same service so which one will be the best approach for networking from Bridge or host network?

///////////////////////////////

 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////


 ////////////////////////////////////////////////////////////////////////////////////////////////////

Comments