0% found this document useful (0 votes)
75 views35 pages

DevOps Lab Manual

Uploaded by

satvikaborra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views35 pages

DevOps Lab Manual

Uploaded by

satvikaborra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY

Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

DEPARTMENT OF CSE-
(ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)

DevOps

LAB RECORD
Regulation: R18/JNTUH

Academic Year: 2023-2024

III B. TECH II SEMESTER

CSE (ARTIFICIAL INTELLIGENCE AND MACHINE LEARNING)

BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY


Mangalpally (Village), Ibrahimpatnam (Mandal), R.R Dist. T.S. Pin-501-510

1
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

CERTIFICATE

This is to certify that Mr./Miss. Branch

Year

bearing H.T. No. has done the bonafide record

work for the Lab in the year

…………………………………

Signature Signature
(Internal Examiner) (External Examiner)

2
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

DEPARTMENT OF CSE

(ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)


VISION AND MISSION OF THE INSTITUTION

Vision
To achieve the Autonomous & University status and spread universal education by inculcating
discipline, character and knowledge into the young minds and mould them into
enlightened citizens.

Mission
To impart high quality education, in a conductive ambience, as comprehensive as
possible, with the support of all the modern technologies and make the students acquire
the ability and passion to work wisely, creatively and effectively for the betterment of
oursociety.
VISION AND MISSION OF CSE DEPARTMENT

Vision
Serving the high quality educational needs of local and rural students within the core
areas of Computer Science and Engineering and Information Technology through a
rigorous curriculum of theory, research and collaboration with other disciplines that is
distinguished by its impact on academia, industry and society.

Mission
The Mission of the department of Computer Science and Engineering is to work closely
with industry and research organizations to provide high quality computer education in
both the theoretical and applications of Computer Science and Engineering. The department
promotes original thinking, fosters research anddevelopment, evolve innovative
applications oftechnology.

3
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

DEPARTMENT OF CSE

(ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)

PROGRAM EDUCATIONAL OBJECTIVES (PEOS):

A graduate of the Computer Science and Engineering Program should:

PEO1 Program Educational Objective1: (PEO1)

The Graduates of Computer Science and Engineering will have successful career in technology or
managerial functions.

PEO2 Program Educational Objective2 :( PEO2)

The Graduates of the program will have solid technical and professional foundation to continue higher
studies

PEO3 Program Educational Objective3: (PEO3)

The Graduates of the program will have skills to develop products, offer services and create new
knowledge.

PEO4 Program Educational Objective4 :( PEO4)

The graduates of the program will have fundamental awareness of industry processes, tools and technologies.

4
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

PROGRAM OUTCOMES (POS):


PO1 Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering
problems.
PO2 Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.

PO3 Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.

PO4 Conduct investigations of complex problems: Use research-based knowledge and research
methods including design of experiments, analysis and interpretation of data, and synthesis of
the information to provide valid conclusions.

PO5 Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities
with an understanding of the limitations.

PO6 The engineer and society: Apply reasoning informed by the contextual knowledge to assess
societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.

PO7 Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need
for sustainable development.

PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9 Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
PO10 Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
PO11 Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a
team, to manage projects and in multidisciplinary environments.

PO12 Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.

5
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

PROGRAM SPECIFIC OUTCOMES (PSOs)

PSO1 Application of AI and ML Knowledge:

Use the foundations of science, math, and engineering together with the concepts of AI and
ML to tackle challenging computer science and engineering challenges.
PSO2 AI and ML Solution Design:
Using cutting-edge engineering and IT techniques, create creative solutions to challenging
engineering challenges involving artificial intelligence and machine learning. Take into account
ethical, sociological, and environmental aspects.
PSO3 AI and ML Research and Development:
To develop and implement cutting-edge artificial intelligence and machine learning solutions that
advance the field and meet societal needs, conduct research-based investigations that include
experiment design, data analysis, and information synthesis.

6
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

DEPARTMENT OF CSE

(ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)

PREREQUISITES:

1. Basic Understanding of Software Development: It's essential to have a foundational


understanding of software development principles, such as coding, version control systems
(e.g., Git), and software development lifecycle.
2. Knowledge of Operating Systems: Familiarity with Linux and Windows operating systems is
beneficial since most DevOps tools and technologies are primarily used in Linux environments.
3. Scripting and Automation Skills: Proficiency in scripting languages like Shell, Python, or Ruby
can be very useful for automating tasks and building scripts for infrastructure management.
4. Understanding of Networking: Basic knowledge of networking concepts, such as IP addresses,
DNS, HTTP, and TCP/IP protocols, will help you in troubleshooting issues and configuring
network setups.
5. Virtualization and Containerization: Understanding virtualization technologies like VMware,
VirtualBox, or containerization platforms.
6. Cloud Computing: Familiarity with cloud platforms such as AWS, Azure, or Google Cloud
Platform is essential as many organizations are adopting cloud services for their infrastructure
needs.

COURSE OBJECTIVES:

 To unify software development (Dev) and IT operations (Ops), enhancing collaboration and efficiency
across the entire development process.

 To increase an organization’s ability to deliver applications and services at high velocity.

 To develop a sustainable infrastructure for specific application and ensure high scalability.

COURSE OUTCOME:

 Accelerate the success rate of software development.

 By learning DevOps, you can condense the production rate.

 Amplified effectiveness through Automation.and enhancing the quality of products and services.

 Enriched communication and collaboration of every production and delivery.


7
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

DEPARTMENT OF CSE

(ARTIFICIAL INTELLIGENCE & MACHINE LEARNING)


Course Name: DevOps Lab Code:
Year/Semester: III/II Regulation: R18
LIST OF EXPERIMENTS
S.No Name of the Experiment Date Page Marks Sign.
No.
1. Write code for a simple user registration form for an
event.

2. Explore Git and GitHub commands

3. Practice Source code management on GitHub.


Experiment with the source code written in exercise 1.

4. Jenkins installation and setup, explore the environment.

5. Demonstrate continuous integration and development


using Jenkins

6. Explore Docker commands for content management

7. Develop a simple containerized application using


Docker.

8. Integrate Kubernetes and Docker

9. Automate the process of running containerized


application developed in exercise 7 using Kubernetes.

10. Install and Explore Selenium for automated testing

11. Write a simple program in JavaScript and perform


testing using Selenium.

12. Develop test cases for the above containerized


application using selenium

8
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-1: Write code for a simple user registration form for an event.

AIM: Write code for a simple user registration form for an event.

1. <Html>
2. <head>
3. <title>
4. Registration Page
5. </title>
6. </head>
7. <body bgcolor="Lightskyblue">
8. <br>
9. <br>
10. <form>
11.
12. <label> Firstname </label>
13. <input type="text" name="firstname" size="15"/> <br> <br>
14. <label> Middlename: </label>
15. <input type="text" name="middlename" size="15"/> <br> <br>
16. <label> Lastname: </label>
17. <input type="text" name="lastname" size="15"/> <br> <br>
18.
19. <label>Course :</label>
20. <select>
21. <option value="Course">Course</option>
22. <option value="BCA">BCA</option>
23. <option value="BBA">BBA</option>
24. <option value="B.Tech">B.Tech</option>
25. <option value="MBA">MBA</option>
26. <option value="MCA">MCA</option>
27. <option value="M.Tech">M.Tech</option>

9
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

28. </select>
29.
30. <br>
31. <br>
32. <label>
33. Gender :
34. </label><br>
35. <input type="radio" name="male"/> Male <br>
36. <input type="radio" name="female"/> Female <br>
37. <input type="radio" name="other"/> Other
38. <br>
39. <br>
40. <label>
41. Phone :
42. </label>
43. <input type="text" name="country code" value="+91" size="2"/>
44. <input type="text" name="phone" size="10"/> <br> <br>
45. Address
46. <br>
47. <textarea cols="80" rows="5" value="address">
48. </textarea>
49. <br> <br>
50. Email:
51. <input type="email" id="email" name="email"/> <br>
52. <br> <br>
53. Password:
54. <input type="Password" id="pass" name="pass"> <br>
55. <br> <br>
56. Re-type password:
57. <input type="Password" id="repass" name="repass"> <br> <br>
58. <input type="button" value="Submit"/>
59. </form>
60. </body>
61. </html>

10
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

OUTPUT:

11
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-2: Explore Git and GitHub commands.

AIM: To Explore Git and GitHub commands.

DESCRIPTION: Git is a popular version control system. It was created by Linus


Torvalds in 2005, and has been maintained by Junio Hamano since then.

It is used for:

 Tracking code changes


 Tracking who made changes
 Coding collaboration

Git Install:
You can download Git for free from the following website: https://www.git-scm.com/

Using Git with Command Line:

To start using Git, we are first going to open up our Command shell.

For Windows, you can use Git bash, which comes included in Git for Windows.
For Mac and Linux you can use the built-in terminal.

The first thing we need to do, is to check if Git is properly installed:

Configure Git:
Now let Git know who you are. This is important for version control
systems, as each Git commit uses this information:

Example

git config --global user.name "<name>"


11
git config --global user.email <email address>

$ git config --global user.name


BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Change the user name and e-mail address to your own. You will probably
also want to use this when registering to GitHub later on.

Creating Git Folder:

Now, let's create a new folder for our project:

mkdir makes a new directory.

cd changes the current working directory.

Now that we are in the correct directory. We can start by initializing Git!

Note: If you already have a folder/directory you would like to use for Git:

Navigate to it in command line, or open it in your file explorer, right-click


and select "Git Bash here"

Initialize Git:

Once you have navigated to the correct folder, you can initialize Git on
that folder:

You just created your first Git Repository!

Note: Git now knows that it should watch the folder you initiated it on.

Git creates a hidden folder to keep track of changes.

12
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Git Adding New Files:

You just created your first local Git repo. But it is empty.

So let's add some files, or create a new file using your favourite text editor. Then
save or move it to the folder you just created.

If you want to learn how to create a new file using a text editor, you can visit our
HTML tutorial:
HTML Editors

For this example, I am going to use a simple HTML file like this:

And save it to our new folder as index.html.

Let's go back to the terminal and list the files in our current working
directory:

ls will list the files in the directory. We can see that index.html is there.

Then we check the Git status and see if it is a part of our repo:

13
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Now Git is aware of the file, but has not added it to our repository!

Files in your Git repository folder can be in one of 2 states:

 Tracked - files that Git knows about and are added to the repository
 Untracked - files that are in your working directory, but not added
to the repository

When you first add files to an empty repository, they are all untracked.
To get Git to track them, you need to stage them, or add them to the
staging environment.

Git Staging Environment:

One of the core functions of Git is the concepts of the Staging


Environment, and the Commit.

As you are working, you may be adding, editing and removing files. But
whenever you hit a milestone or finish a part of the work, you should add
the files to a Staging Environment.

Staged files are files that are ready to be committed to the repository
you are working on. You will learn more about commit shortly.

For now, we are done working with index.html. So we can add it to the
Staging Environment:

14
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Git Commit:
Adding commits keep track of our progress and changes as we work. Git considers
each commit change point or "save point". It is a point in the project you can go back to if
you find a bug, or want to make a change.

When we commit, we should always include a message.

By adding clear messages to each commit, it is easy for yourself (and others) to see what
has changed and when.

The commit command performs a commit, and the -m "message" adds a message.

The Staging Environment has been committed to our repo, with the message:
"First release of Hello World!"

15
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Git Commit Log:


To view the history of commits for a repository, you can use the log command:

 git clone <remote-repo-address>: copy the entire repository from a remote server to
remote directory. You can also use it to copy local repositories.
 git config use to set user-specific configurations like email, username, and file
format.
 git status shows the list of changed files or files that have yet to be staged and
committed.
 git push <remote-name> <branch-name>: send local commits to remote branch of
repository.
 git checkout -b <branch-name>: creates a new branch and switches to a new
branch.
 git remote –v: view all remote repositories.
 git remote add <remote-name> <host-or-remoteURL>: add remote server to local
repository.
 git branch –d <branch-name>: delete the branch.
 git pull merge commits to a local directory from a remote repository.
 git merge <branch-name>: after resolving merge conflicts the command blends
selected branch into the current branch.
 git log show a detailed list of commits for the current branch.

16
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-3: Practice Source code management on GitHub. Experiment


with the source code written in exercise 1.

AIM: Practice Source code management on GitHub.

Experiment with the source code written in exercise 1

DESCRIPTION:

Source code is generally understood to mean programming statements that are


created by a programmer with a text editor or a visual programming tool and
then saved in a file.

Source code management (SCM) is used to track modifications to a source code


repository. SCM tracks a running history of changes to a code base and helps
resolve conflicts when merging updates from multiple contributors. SCM is also
synonymous with Version control.

GitHub is an Internet hosting service for software development and version


control using Git. It provides the distributed version control of Git plus access
control, bug tracking, software feature requests, task management, continuous
integration, and wikis for every project.

To practice source code management on GitHub, you can follow these steps:

 Create a GitHub account if you don’t already have one.


 Create a new repository on GitHub.
 Clone the repository to your local machine: $ git clone <repository- url>
 Move to the repository directory: $ cd <repository-name>
 Create a new file in the repository and add the source code written in
exercise 1.
 Stage the changes: $ git add <file-name>
 Commit the changes: $ git commit -m “Added source code for a simple user
registration form”
 Push the changes to the remote repository: $ git push origin master
 Verify that the changes are reflected in the repository on GitHub.

These steps demonstrate how to use GitHub for source code management.

17
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO- 4: Jenkins installation and setup, explore the environment.

AIM: Jenkins installation and setup, explore the environment

DESCRIPTION:

Jenkins is a popular open-source tool for Continuous Integration and


Continuous Deployment (CI/CD) in software development.

Here are the steps to install and set up Jenkins:

1. Install Java Development Kit (JDK)

 Download JDK 11 or JDK 17 and choose windows 32-bit or 64-bit according to


your system configuration. Click on "accept the license agreement."

2. Set the Path for the Environmental Variable for JDK

 Go to System Properties. Under the "Advanced" tab, select "Environment


Variables."
 Under system variables, select "new." Then copy the path of the JDK folder and
paste it in the corresponding value field. Similarly, do this for JRE.
 Under system variables, set up a bin folder for JDK in PATH variables.
 Go to command prompt and type the following to check if Java has been
successfully installed:
C:\Users\Simplilearn>java –version

3. Download and Install Jenkins

 Download Jenkins by clicking here https://www.jenkins.io/download/ Under


LTS, click on windows.
 After the file is downloaded, unzip it. Click on the folder and install it. Select
"finish" once done.

18
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

4. Run Jenkins on Localhost 8080

 Once Jenkins is installed, explore it. Open the web browser and type
"localhost:8080".
 Enter the credentials and log in. If you install Jenkins for the first time, the
dashboard will ask you to install the recommended plugins. Install all the
recommended plugins.

5. Jenkins Server Interface

 New Item allows you to create a new project.


 Build History shows the status of your builds.
 Manage System deals with the various configurations of the system.

6. Build and Run a Job on Jenkins

 Select a new item (Name - Jenkins_demo). Choose a freestyle project and click
Ok.
 Under the General tab, give a description like "This is my first Jenkins job."
Under the "Build Triggers" tab, select add built step and then click on the
"Execute Windows" batch command.
 In the command box, type the following: echo "Hello... This is my first Jenkins
Demo: %date%: %time% ". Click on apply and then save.
 Select build now. You can see a building history has been created. Click on that.
In the console output, you can see the output of the first Jenkins job with time
and date.
Congratulations, you've just installed Jenkins on your Windows system!

19
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-5: Demonstrate continuous integration & development using


Jenkins.

AIM: To demonstrate continuous integration & development using Jenkins..

DESCRIPTION:

 Create a simple Java application that you want to integrate with Jenkins.
 The application should have some basic functionality, such as printing
“Hello World” or performing simple calculations.
Commit the code to a Git repository:

 Create a Git repository for the application and commit the code to the
repository.
 Make sure that the Git repository is accessible from the Jenkins server.
Create a Jenkins job:

 Log in to the Jenkins web interface and create a new job.


 Configure the job to build the Java application from the Git repository.
 Specify the build triggers, such as building after every commit to the
repository.
Build the application:

 Trigger a build of the application using the Jenkins job.


 The build should compile the code, run any tests, and produce an executable
jar file.
Monitor the build:

 Monitor the build progress in the Jenkins web interface.


 The build should show the build log, test results, and the status of the build

20
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510
Deploy the application:

 If the build is successful, configure the Jenkins job to deploy the application
to a production environment.
 The deployment could be as simple as copying the jar file to a production
server or using a more sophisticated deployment process, such as using a
containerization technology like Docker.
Repeat the process:

 Repeat the process for subsequent changes to the application.


 Jenkins should automatically build and deploy the changes to the production
environment.

This is a basic example of how you can use Jenkins to demonstrate CI/CD in
Software development. In a real-world scenario, you would likely have more
complex requirements, such as multiple environments, different types of tests, and
a more sophisticated deployment process. However, this example should give you
a good starting point for using Jenkins for CI/CD in your software development
projects.

21
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-6: Explore Docker commands for content management.

AIM: To Explore Docker commands for content management.

DESCRIPTION: Docker has become an integral part of software engineering. We


use Docker for development, testing, and deployment because it’s easy to manage
the environment. Because of its portability, it has become popular in the software
industry. That means if your code works in development, it will work in production.
Moreover, developers can collaborate faster without worrying about which software
dependency they need to install.

Here are some commonly used Docker commands for content management:

1. docker search

We can use the command docker search to search for public images on the Docker
hub. It will return information about the image name, description, stars, official and
automated.

docker search MySQL

2. docker pull

Now that we know the name of the image, we can pull that from the Docker hub
using the command docker pull. Here, we are setting the platform option as well.

docker pull --platform linux/x86_64 mysql

22
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

Tags are used to identify images inside a repository. If we don’t specify a tag
Docker engine uses the :latest tag by default. So, in the previous example, Docker
pulled the mysql:latest image.

If our application depends on a specific version of an image, we can specify that


using a tag name.

docker pull --platform linux/arm64/v8 mysql:5.6

Since we can have multiple images under one repository, we can pull all the images
using the --all-tags option. The following command will pull all the images from
the mysql repository.

docker pull --all-tags mysql

Brilliant, now we should have some images in our local machine, and to confirm,
let’s run the following command to list all the local images.

docker images

23
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

4. docker run

Alright, now that we have some images, we can try to create a container. Here we
used the --env option to set a mandatory environment variable and --detach option
to run the container in the background.

docker run --env MYSQL_ROOT_PASSWORD=my-secret-pw --detach mysql

Moreover, we can use the --name option to assign a name to the container. Docker
will randomly assign a name if we don’t provide one.

5. docker ps

We can list all the running containers by using the following command.

docker ps

How about listing all the containers, including the stopped ones? We can do that by
adding --all option.

docker ps --all

24
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

6. docker stop

To stop a container, use the docker stop command with either the container id or
container name. We may stop a container if we want to change our docker run
command.

docker stop f8c52bedeecc

7. docker restart

Let’s restart our stopped contained by using the following command. We may want
to use this after we reboot our machine.

docker restart f8c52bedeecc

8. docker rename

Now, let’s change the container name from compassionate_fermi to test_db. We


may want to change the name to keep track of our containers more easily.

docker rename compassionate_fermi test_db

25
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

9. docker exec

Access the running container test_db by running the following command. It’s
helpful if we want to access the MySQL command line and execute MySQL
queries.

docker exec -it test_db bash


mysql -uroot -pmy-secret-pw
SHOW DATABASES;

The -i and -t options are used to access the container in an interactive mode. Then
we provide the name of the container we want to access, which in this case test_db.
Finally, the bash command is used to get a bash shell inside the container.

10. docker logs

This command is helpful for debugging our Docker containers. It will fetch logs
from a specified container.

docker logs test_db

If we want to continue to stream new output, we can use the option -follow.

docker logs -follow test_db

26
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

11. docker rm

If we want to remove a container, we can use the following command.

docker rm test_db

You may encounter an error like

Error response from daemon: You cannot remove a running container ……… Stop
the container before attempting removal or force remove

As it recommends, we can stop the container first and then remove it or use the
option -f to remove a running container forcefully.

docker stop test_db


docker rm test_db
# or
docker rm -f test_db

12. docker rmi

Finally, if we want to free some disk space, we can use the docker rmi command
with the image id to remove an image.

docker rmi eb0e825dc3cf

These commands come with plenty of helpful options. If you want to know about
other available options, run the docker command_name --help command. For
example:

docker logs --help

27
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-7: Develop a simple containerized application using Docker.

AIM: To Develop a simple containerized application using Docker.

DESCRIPTION: Here’s an example of how you can develop a simple containerized


application using Docker:

Choose an application:

 Choose a simple application that you want to containerize. For example, a


Python script that prints “Hello World”. Write a Dockerfile:
 Create a file named “Dockerfile” in the same directory as the application. In
the Dockerfile, specify the base image, copy the application into the
container, and specify the command to run the application. Here’s an
example Dockerfile for a Python script:

Use the official Python image as the base image

FROM python:3.

Copy the Python script into the container

COPY hello /app/

Set the working directory to /app/

WORKDIR /app/

Run the Python script when the container starts

CMD [“python”, “hello”]

28
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

 Build the Docker image: Run the following command to build the Docker
image: $ docker build -t myimage. This command builds a new Docker
image using the Dockerfile and tags the image with the name “myimage”.

 Run the Docker container: Run the following command to start a new
container based on the image: $ docker run –name mycontainer myimage
This command starts a new container named “mycontainer” based on the
“myimage” image and runs the Python script inside the container.

 Verify the output: Run the following command to verify the output of the
container: $ docker logs mycontainer This command displays the logs of the
container and should show the “Hello World” output.

This is a simple example of how you can use Docker to containerize an


application. In a real-world scenario, you would likely have more complex
requirements, such as running multiple containers, managing network connections,
and persisting data. However, this example should give you a good starting point
for using Docker to containerize your applications.

29
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-8: Integrate Kubernetes and Docker.

Use Docker to build a Docker image of your application. You can use a Docker
file to specify the base image, copy the application into the container, and specify
the command to run the application.

 Push the Docker image to a registry:


 Push the Docker image to a container registry, such as Docker Hub or
google Container Registry, so that it can be easily accessed by Kubernetes.
 Deploy the Docker image to a Kubernetes cluster:
 Use Kubernetes to deploy the Docker image to a cluster. This involves
 Creating a deployment that specifies the number of replicas and the image to
 Be used, and creating a service that exposes the deployment to the network.
 Monitor and manage the containers:
o Use Kubernetes to monitor and manage the containers. This includes
scaling.
o The number of replicas, updating the image, and rolling out updates to
the

Containers.

 Continuously integrate and deploy changes.


 Use a continuous integration and deployment (CI/CD) pipeline to
 Automatically build, push, and deploy changes to the Docker image and the
Kubernetes cluster. This makes it easier to make updates to the application
and ensures that the latest version is always running in the cluster.
 By integrating Kubernetes and Docker, you can leverage the strengths of
both technologies to manage containers in a scalable, reliable, and efficient
manner.

30
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-9: Automate the process of running containerized application


developed in exercise 7 using Kubernetes.

AIM: Automate the process of running containerized application developed in


exercise 7 using Kubernetes.

DESCRIPTION:To automate the process of running the containerized application


developed in exercise 7 using Kubernetes, you can follow these steps:

 Create a Kubernetes cluster.


 Create a Kubernetes cluster using a cloud provider, such as Google
Cloud or Amazon Web Services, or using a local installation of
Minikube.
 Push the Docker image to a registry:
 Push the Docker image of your application to a container registry,
such as Docker Hub or Google Container Registry.
 Create a deployment:
 Create a deployment in Kubernetes that specifies the number of
replicas and the Docker image to use. Here’s an example of a
deployment YAML file:apiVersion: apps/v kind:
Deploymentmetadata:targetPort: 80 type: ClusterIP
 Apply the deployment and service to the cluster:
 Apply the deployment and service to the cluster using the kubectl
command-line tool. For example:
 $ kubectl apply -f deployment $ kubectl apply -f service.
 Verify the deployment:
 Verify the deployment by checking the status of the pods and the
service. For Example:
$ kubectl get pods
$ kubectl get services
This is a basic example of how to automate the process of running a containerized
application using Kubernetes.In a real-world scenario, you would likely have
more complex requirements, such as managing persistent data, scaling, and rolling
updates, but this example should give you a good starting point for using
Kubernetes to manage your containers.
31
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-10: Install and Explore Selenium for automated testing.

AIM: Install and Explore Selenium for automated testing

DESCRIPTION: To install and explore Selenium for automated testing, you can
follow these steps:

 Install Java Development Kit (JDK):


 Selenium is written in Java, so you’ll need to install JDK in order to
run it. You can download and install JDK from the official Oracle
website. Install the Selenium WebDriver:
 You can download the latest version of the Selenium WebDriver from
the Selenium website. You’ll also need to download the appropriate
driver for your web browser of choice (e. Chrome Driver for Google
Chrome). Install an Integrated Development Environment (IDE):
 To write and run Selenium tests, you’ll need an IDE. Some popular
choices include Eclipse, IntelliJ IDEA, and Visual Studio Code.

32
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-11: Write a simple program in JavaScript and perform testing


using Selenium.

AIM: To develop a simple program in JavaScript and perform testing using


Selenium

PROGRAM:

 Simple JavaScript program that you can test using Selenium

<!DOCTYPE html>

<html>

<head>

<title>Simple JavaScript Program</title>

</head>

<body>

<p id=”output”>0</p><button id=”increment-


button”>Increment</button>
<script>
const output = document(“output”);
const incrementButton =Document (“increment-button”);
Let count = 0; incrementButton(“click”, function()
{

count += 1;
output = count;
}
</script>
</body>

</html>
33
BHARAT INSTITUTE OF ENGINEERING & TECHNOLOGY
Mangalpally(Village),Ibrahimpatnam(Mandal).: .R.R Dist. T.S. Pin-501-510

EXPERIMENT NO-12: Develop test cases for the above containerized application
using Selenium.

AIM: To develop test cases for the above containerized application using Selenium.

Selenium import org.openqa.selenium;


import org.openqa.selenium;
import org.openqa.selenium.chrome;
import org.junit;
import org.junit;
import org.junit;
Public class Main { private WebDriver driver;
@Before public void setUp()
{

System(“webdriver.chrome”, “path/to/chromedriver”);
driver = new ChromeDriver(); }
@Test public void testIncrementButton()
{
driver(“file:”);
driver(By(“increment-button”)).click();
String result = driver(By(“output”)).getText();
assert result(“1”);
}

34

You might also like