Self Docker Notes Class
Self Docker Notes Class
Front End : refers to the UI. It is the front end with which user interacts
It can be developed by the use of html/css/react js/angular js
Developer writes the code for the application and Devops Engineer is responsible for deploying or
executing the application.To deploy an application he needs the following enviornmental setup
.
MACHINE
Application Code
_____________________
React JS v16
live Server
Java v17
Tomcat v9
Oracle v12
_________________________
Operating System
Once all the above dependencies installed then only the Appliction will be executed.
Developer develops the code . Now the code has to be tested in different Application Environments
1) DEV Enviornment 2) SIT Env 3) UAT envio 4)Pre Prod envio 5) Prod enviornment
In each enviornment DEVOPS engineer need to take on computer and install the above
dependencies with the correct version.
Dev Enviornment : The developers after developing the code ,test the units code to check whether it
is working in the desired manner or not. After testing the code in DEV environment we go next
with SIT Enviornment
SIT Enviornment: In our Project the software testing team is their to carry out the System
Integration Testing.
Here also the same enviornmental set up is done.
UAT enviornment:(User Acceptance Testing): Here the Client test the code wheteher the code is
fulfiling all the requirements or not. (It is called to be the test drive for the client which is very
similar to the test drive of a vehicle when we visit showroom to purchase the bike or the car)
PreProd enviornment: A final testing of the application has to be carried out before it goes for the
Production Enviornment
Devops Engineer must deploy the application in different enviornments or it is duty of devops
engineer to install the machine with the required depenedencies in all the above enviornments.
Let us consider the scenarion in which the DEVops enginner in SIT enviornment installed java
version 12 instead of 17
then the code will not work . The same code that runs in DEV envirnment does not run in the SIT
enviornment .These issues are called as enviornmental issues often comes when we install the
dependencies manually from one enviornment to another.
To execute our application in all the enviornments it is necessary to install the correct versions of
the dependencies .If manually it is donethen there is the chance of human error or mistakes that
disturb or halt the application execution.
Docker is a containerization software that simplifies the execution of the project in multiple
enviornments.no need to install the required dependencies’ manually if we use docker then docker
itself installed the required dependencies.
Answer is DOCKER.
1) Dockerfile : It contains set of instructions to download dependencies and build docker image
4) Docker Container : When run docker image it will run Our application inside Container.
6) The command will not work because first of all we have to make ec2 user as a part of the docker
group
Note: Detached mode will help us to run other commands in same tab
https://hub.docker.com/
In Docker Hub the default image is hello-world
In order to fetch the image in AWS Linux Machine type the following Command
a)docker pull hello-world
The message generated shows the communication process between the docker daemon and the
docker client
Note: In the above command we are mapping container port to host port to
access application outside of the container.
=> After running application with above command we need to enable host port
in security group inbound rules.
1) FROM
2) MAINTAINER
3) RUN
4) CMD
5) COPY
6) ADD
7) WORKDIR
8) EXPOSE
9) ENTRYPOINT
10) USER
11) ARG
12) VOLUME
1) FROM: It refers to the base image from which our image is created
In From we specify the software along with its version that are needed to execute the application.
(for example: In order to run the java application, I need jdk1.8
Similarly i also need mysql server version 10.1)
FROM python:3.6
FROM jdk:1.8
3)RUN:is used to execute the instructions when the docker image is creating
for example before the build happens I want to download the entire repository from the GIT HUB
by typing the command :RUN 'git clone <url of the repository>'
Note: The instructions to be executed during the docker image creating must
be written after the RUN and must be enclosed in single colon.
4)CMD: instructions are executed when the docker image is runnning inside the
docker container or when the docker container is creating.
My Spring Boot application is ready and I want to exeute the jar file or move war file to tomcat etc...
docker images
It will display ubuntu image
To run CMD type docker run myImage1 only last cmd instructions will be executed.
5)COPY:It is used to copy the files from host machine to container machine
Ex:
6)ADD command
=============
=> It is used to copy the files from host machine to container machine
Ex:
7) WORKDIR Keyword
It is used to specify working directory location to process further docker file instructions
EX:
WORKDIR /usr/app
8)EXPOSE Keyword
===============
Ex:
EXPOSE 8080
Note: By using EXPOSE keyword can't modify docker container port (it is just to provide
information).
9)ENTRYPOINT
It is used to run our application code in docker container
Ex:
10)USER keyword
Ex:
USER root
USER ec2-user
11)ARG Keyword
EX :
ARG branch-name
12)VOLUME keyword
It is used to specify DOCKER volume for storing the data
Ex:
VOLUME mysql-db-data
=====================
Sample Dockerfile
====================
$ vi Dockerfile
FROM ubuntu
MAINTAINER SumitMiglani<[email protected]>
$ docker images
===============================================
How to push Docker Image to Docker Hub Account
===============================================
We can change docker-file name then we have to pass that file name in build command like below