Devops Practical
Devops Practical
PRACTICAL FILE
C
Submitted by: Submitted to :
Aditya Kumar 2021007 ; 2004882 Pf .Kamaljit Kaur
Index
S.N PRACTICAL NAME DATE SIG P A
O N GE
NO
1 Install GIT 4-6
Practical 1
● Install Git
2.Once the download is complete, run the installer and follow the on-screen
instructions. The installer will guide you through the installation process and
allow you to customize certain options. Allow the app to make changes to
your device by clicking Yes on the User Account Control dialog that opens.
3. The installer will ask you for an installation location. Leave the default, unless you
have reason to change it, and click Next.
4.During the installation, you will be prompted to choose the default editor
for Git. You can choose your preferred text editor, such as Sublime Text,
Atom, or Visual Studio Code, or you can use the default editor provided by
Git.
PRACTICAL2
1. Open your web browser and navigate to the GitHub website at https://
github.com/.
2. Click the "Sign up" button in the top-right corner of the page.
4. Choose your plan. GitHub offers both free and paid plans, depending
on your needs. If you're just getting started, the free plan should be
sufficient.
puzzle.
7. Verify your email address by clicking the link in the confirmation email
that GitHub sends to the email address you provided during the signup
process.
8. Once your email address has been verified, you can log in to your
GitHub account and start using it to host and manage your code
repositories.
That's it! You've now successfully created an account on GitHub and can
start exploring all of its features and functionality.
PRACTICAL 3
● Create Repository using GIT/ GITHUB
1. After successfully setting up GitHub account login to your account.
You will see the screen as below.
4. After clicking the button, we will be directed to below page. Right now
the only file we have is a readme file.
6. Follow the steps mentioned in the Picture below and click “commit
changes”
7. Now you will see that all of our files uploaded in our github
Practical No 4
● Create/Delete/Merge Branches
Branching means you diverge from the main line of development and continue to do
work without messing with that main line. In many VCS tools, this is a somewhat
expensive process, often requiring you to create a new copy of your source code
directory, which can take a long time for large projects.
1. Checking for the existing branches : Use the command git branch . This will
fetch the list of all existing branches present in your git repository. Below we
haveonly have branch existing in the repository i,e main branch.
2. Creating a new branch : Using the command git branch , followed by the name
of the branch , we can create a new branch in a repository
3. Checking out to a new branch : The git branch option creates a new branch but
in order to start working on it, we need to checkout to that branch. This can be
achieved by using the command git checkout followed by the name of the branch
you want to checkout on to.
4.
Practical No 5
● Install Jenkins
Jenkins is one of the most popular open source automation server solutions for
continuous integration and continuous delivery on any platform. As a Java
application, Jenkins has many plugins for automating almost everything at the
infrastructure level.The use of Jenkins has widely increased in the developer
community due to this rich set of functionalities, which it provides in the form of
plugins.
By installing Jenkins, teams can then start using Jenkins at scale to incorporate
automation into their development cycles for improving code quality and getting
immediate feedback. This is truly the way to shift left and introduce agility in your
development lifecycle.
Install Jenkins on Windows
5. Under the Run service as a local or domain user option, enter the
domain username and password for the user account you want to run
Jenkins with. Click Test Credentials to verify the login data, then click
Next to proceed.
6. Enter the port number you want Jenkins to run on. Click Test Port to check if the
selected port is available, then click Next to continue.
7. Select the directory where Java is installed on your system and click Next to
proceed.
8. Select the featuíes you want to install with Jenkins and click Next to
continue.
10. Once the installation is complete, click Ïinish to exit the install wizaíd.
UNBLOCK JENKINS
After completing the installation process, you have to unblock Jenkins before you can
customize and start using it.
1. In your web browser, navigate to the port number you selected during the
installation using the following address:
http://localhost:[port number]
CUSTOMIZE JENKINS
1 Click the Install suggested plugins button to have Jenkins automatically install
the most fíequently used plugins.
3. On the Instance Configuíation page, confiím the poít numbeí you want
Jenkins to use and click Save and Ïinish to finish the initial customization.
Once you click on start using Jenkins, you will be redirected to the
dashboard screen as shown.
This completes the installation and setup process and we can now proceed to
create a new job on jenkins
Practical 6
Step 2: In the next screen, enter the Item name, in this case we have named it Helloworld.
Choose the ‘Freestyle project option’
Step 3: The following screen will come up in which you can specify the details of the job
Step 4: We need to specify the location of files which need to be built. In this example, we will
assume that a local git repository(E:) has been setup which contains a ‘HelloWorld.java’ file.
Hence scroll down and click on the Git option and enter the URL of the local git repository
5: Now go to the Build section and click on Add build step → Execute Windows batch
command
Step 6: In the command window, enter the following commands and then click on the
Save button. Javac HelloWorld.java Java HelloWorld
7: Once saved, you can click on the Build Now option to see if you have successfully
defined the job.
Step 8: Once the build is scheduled, it will run. The following Build history section shows
that a build is in progress.
Step9: Once the build is completed, a status of the build will show if the build was
successful or not. In our case, the following build has been executed successfully. Click on
the 1 in the Build history to bring up the details of the build.
Figure 6.9: Execution Of Build Step 10: Click on the Console Output link to see the
details of the build.
Practical 7
Step 1: Create a Jenkins job, You now need to create a Jenkins job. To do so, click New
Item (1). Or, if it’s a clean install, click on create new jobs (2).
Step 2: Use a GitHub Repository Scroll down a bit more and you’ll see the Pipeline
section, where we’ll tell Jenkins to use the GitHub repo as the source. In the Definition
dropdown, choose Pipeline script from SCM to configure the repo.
Step 3: Configure the GitHub Hook Trigger In the screen you see now, scroll down a little
to the Build Triggers section. We’re going to make sure that this Jenkins job runs only
when someone pushes a change in the GitHub repo. You can configure other actions, like
when someone creates a pull request. But for simplicity’s sake, we’ll stick with the push
action only. Of course, you can always run the job manually, but that’s not ideal. So,
choose the GitHub hook trigger for GITScm polling option.
Step 4: Add a Webhook in Github Now, go to the GitHub project because it’s time to
configure the webhook so that GitHub can trigger the Jenkins job after every push in the
repo. In your project, click on the Settings (1) tab, then click Webhooks (2) from the left
panel. Now, click on the Add webhook (3) button at the right. Here’s a screenshot for
reference:
Step 5: Now go to the Build section and click on Add build step → Execute shell
Step 7: Change Something in the GitHub Repo. You finished the integration with GitHub
in the previous step. But because you and I are good citizens, let’s make sure that this
integration works fully. So, go to the GitHub repository and change something, commit,
and push. In my case, I added a new stage in the Jenkins pipeline to include more tests.
Wait for a few seconds, and you should see another successful run of the job. If you go the
logs for the second time the job ran, you’ll notice something different at the beginning of
the logs saying that GitHub started it, along with the username:
Practical 8
● Install Docker
Step 1: Double-click Docker Desktop Installer.exe to run the installer. If you haven’t
already downloaded the installer (Docker Desktop Installer.exe), you can get it from
Docker Hub. It typically down- loads to your Downloads folder, or you can run it from the
recent downloads bar at the bottom of your web browser.
Step 2: When prompted, ensure the Use WSL 2 instead of Hyper-V option on the
Configuration page is selected or not depending on your choice of backend.
Step 3: Follow the instructions on the installation wizard to authorize the installer and
proceed with the install.
Step 4: When the installation is successful, click Close to complete the installation
process.
Step 5: If your admin account is different to your user account, you must add the user to
the docker-users group. Run Computer Management as an administrator and navigate to
Local Users and Groups
> Groups > docker-users. Right-click to add the user to the group. Log out and log back
in for the changes to take effect.
Practical 9
Deploy Nginx Web Server Image 0n Docker
Now visit http://localhost with your browser. You will see the default “Welcome to
nginx!” page. We are now running an nginx container.
Practical 10
Apache web server is popular open source http web server tool which is widely used for
deployment of webpages. It can be installed in any operating system. We can create any
Apache web server image in two ways.
Step 1: Download the Docker image, which contains Apache called httpd, by running the
docker pull command below. This command will download or pull the Apache image from
the Docker registry, as shown below.
Step 2: Next, confirm you’ve downloaded the image by running the docker images
command below to list all images available on your computer.
Step 3: Invoke the docker run command to create a new container based on your
downloaded Apache Docker image.
Step 4: Once the Apache container is running, verify if you can access the Apache web
interface by navigating to Public-Ip-address:80 using your web browser. If you can see the
same message, as you can see below, then you’ve successfully started your Apache
Docker container.
Step 5: Finally, stop the container if you don’t need it running anymore by running the
docker stop command below. This command will gracefully stop the container instance.
Practical 11
Now visit http://localhost with your browser. You will see the default “Welcome to
nginx!” page. We are now running an nginx container.
Practical 12
Step 1: First we have to create a base container. The following command will create a base
container if the nginx version is latest otherwise it will automatically pull latest version of
nginx from DockerHub:
Step 2: Now we can see that our container is running using the docker ps -a command:
Step 3: Then we have to create a commit for the running container to save it as an image.
Step 4: Then we see our images list. You can see there is a new image and it does not
have a repository or tag, but it exists. This is an image created from the running
container.
Step 5: When we made the commit, it created an image without a tag or name. You’ll see
an image listed with ¡none¿ as both the ID and name.Using docker tag, we can name the
image we just created.
Step 6: Now, if you issue the command docker images, you’ll see your new image with
the name my- customimg.
Practical 13
By pushing an image to the Docker hub registry, we can create an instance of an image in
which a particular type of software and applications are pre-installed and can be pulled
again whenever you want to work on that particular type of image or applications and run
that kind of virtual machine.
Step 1: First login to Docker Hub using your username and password when prompted. Use
following command: docker login -u <username>
Step 2: Build your docker image. Step 3: Push image to Docker Hub
Step 4: Add Additional Tags to Your Docker Image You often want to include tags like
version in addition to the latest tag. To add a version tag you write the following
commands:
Practical 14
In docker, the persistent storage is dealt with the volume concept. Persistent storage is
means when we are stopping or removing the container the data should be persistent. It
will not delete automatically once the docker container is not available. We can define the
persistent storage layer while launching the docker container. Once it will define, the
actual data will be store on the external storage layer which is not a part of the docker
environment. The storage layer will be on the host machine, remote machine, on the
cloud, etc. Before directly going to the docker persistent storage, we need to first
understand the storage layer availability on the docker platform. It will help to understand
the storage layer concept.
We are having the list of docker images. The docker images are available on the docker
hub. If we need to create our own images then we can also build a new or own image.
Please note, while creating the new image, we need to choose the respective base image
like centos, Ubuntu, windows, etc. Once the image is ready, we can run the container in
the docker. If we are normally running the container without any storage definition then
the docker data is in a volatile state. In the docker, there are three different ways that the
data will be store. 1. bind mounts 2. volumes 3. in-memory storage (tmpfs)
Bind mounts: The bind mounts are a very older method to mount the file or the directory
to the docker container. The bind mount is having limited functionality as compared to the
volume. When we are using the bind mount method, we are using the local file or the local
directory to the docker container. We need to define the complete path of the local file or
the local directory of the local machine into the docker container. While working with the
bind mounts, we need to rely on the local machine file structure. We need to follow the set
of rules and regulations which is imposed on the local system.
Volumes: The volume storage is also known as the persistent data storage layer of the
docker. The default path for the docker volume is /var/lib/docker/volumes. Whenever we
are creating or associating the volume to the docker container. The volume will by default
store on the “/var/lib/docker/volumes” path. Volume is very easier to mount or for the
migration. If we are deleting the docker container but the volume is still present on the
storage layer. Then the same volume we can use for the next or the different docker
container. It will use the same data which was previously used by the older container.
In-memory storage (temporary storage file): When we are launching the docker container
without defining the storage layer like mount or volume. The docker container will run
under the in-memory storage file system. It will store the data temporarily. Once we are
deleting or stopping the respective docker container the data will vanish. The working data
is not present in it. We need to rerun or load the data one more time if we need to work on
the same docker container. In the docker environment, we are able to add persistent
storage to the docker image.