0% found this document useful (0 votes)
38 views29 pages

Cloud Lab Fin

cloud computing

Uploaded by

22csa38
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)
38 views29 pages

Cloud Lab Fin

cloud computing

Uploaded by

22csa38
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/ 29

Ex No: 1 Install Virtual box/VMware Workstation with different flavours of

Linux or windows OS on top of windows7 or8.

AIM:

To find procedure to Install Virtual box/ VM ware Workstation


with different flavors of Linux or windows OS on top of windows 7 or 8.

PROCEDURE:

1. Hosted Virtualization on Oracle Virtual Box Hypervisor

Step1: Download OracleVirtualbox

fromhttps://www.virtualbox.org/wiki/Downloads

Step2: Install it in Windows, once the installation has done open it.

Step 3: Create Virtual Machine by clicking on New.

Step4: Specify RAM Size, HDD Size, and Network Configuration and Finish the wizard.

1
Step5: To select the media for installation Click on start and browse for iso file. In this
example we are selecting Ubuntu Linux iso.

Step 6: Complete the Installation and use it. Now complete the installation using standardizes
instructions to use it.

2
RESULT:
Thus Virtual box/VMware workstation with different flavors of Linux or windows OS
on top of windows7or 8 is successfully executed.

3
Ex No: 2 Install a C compiler in the virtual machine created using virtual box and execute
Simple Programs

AIM:

To install ‘C’ compiler inside that virtual machine and execute programs.

PROCEDURE:

The package GCC needs to be installing to use C compiler. The GNU Compiler
Collection (GCC) is a collection of compilers and libraries for C, C++, Objective-C,
FORTRAN, Ada, Go, and D programming languages. Many open-source projects, including
the GNU tools and the Linux kernel, are compiled with GCC. The steps for installing GCC
and running C programs are as follows.

Step 1: Installing GCC on Ubuntu


The default Ubuntu repositories contain a meta-package named build-essential that
contains the GCC compiler and a lot of libraries and other utilities required for compiling
software. First start by updating the packages list.
$sudoapt update

Now install the build –essential package by using following command.


$sudoapt install build-essential

Step2: Check the GCC version for “C” Compiler


To validate that the GCC compiler is successfully installed, use the gcc– version
command which prints the GCC version:
$gcc–version
The output will show the appropriate GCC version like gcc (Ubuntu7.4.0-1ubuntu1~18.04) 7.4.0

Step3: Write C program using Gedit editor


To use Gedit, Open Terminal (Applications_Accessories_Terminal). Open gedit
by typing “gedit” on terminal or open Gedit application from application menu.

Step 4: Write a simple Hello world program using C.

4
Inside the gedit editor, write a simple calculator program as shown below.
# include<stdio.h>
int main()
{
printf ("Hello World\n");
return0;
}

Save this file as “hello.c”, compile it on terminal using command,


$gcc-o hello hello.c

Here –oisusedtocreateaseparateoutputfileforourprogramotherwiseitcanberunthrougha.out file.


As we have created a separate output file, run the program using command. $./Hello

RESULT:

Thus C compiler was installed successfully and executed a simple program.

5
Ex No: 3 Install Google App Engine. Create hello world app and other simple web
applications using python/java.

AIM:
Write a procedure Install Google App Engine, create hello world app, and other
simple web Applications using Python.
PROCEDURE:
The App Engine SDK allows you to run Google App Engine Applications on your local
computer. It simulates the run Gtime environment of the Google App Engine infrastructure.
Pre-Requisites: Python2.5.4

If you don't already have Python 2.5.4installed in your computer, download and Install
Python 2.5.4 from.

Download and Install

∙ You can download the Google App Engine SDK by going to download the appropriate install
package.

∙ Download the Windows installer–the simple thing is to download it to your Desktop or


another folder that your e member.

∙ Double Click on the Google Application Engine installer.


∙ Click through the installation wizard, and it should install the App Engine. If you do not have

Python 2.5, it will install Python 2.5 as well. Once the install is complete you can discard the
downloaded installer.

6
Making your First Application

Now you need to create a simple application. We could use the “+” option to have the launcher make
us an application –but instead we will do it by hand to get a better sense of what is going on. Make a
folder for your Google App Engine applications. I am going to make the Folder on my Desktop
called “apps”–the path to this folder is:

C:\Documentsand Settings\cse\Desktop\apps

And then make a sub-folder in within apps called “ae-01-trivial” – the path to this folder
would be:

C:\DocumentsandSettingscsev\Desktop\apps\ae-01-trivial

Using a texted it or such as Jedit (www.jedit.org),createa file called app.yamlin the ae-01-
trivial Folder with the following contents:

Application: ae-01-
trivialversion:1
runtime: pythonapi_version:1
handlers:-
url:/.*script:index.py

Note: Please do not copy and paste these lines into your text editor –you might end up with
strange characters –simply type them into your editor.
Then create a file in the ae-01-trivial folder called index.py with three lines in it:
Print 'Hello world!'

7
Then start the GoogleAppEngineLauncher program that can be found under Applications. Use
the File->Add Existing Application command and navigate into the apps directory and select the
ae-01-trivial folder. Once you have added the application, select it so that you can control the
application using the launcher.

Once you have selected your application and press Run. After a few moments your application will
start and the launcher will show a little green icon next to your application. Then press Browse to
open a browser pointing at your application which is running at http://localhost:8080/

Paste http://localhost:8080into your browser and you should see your application as follows:

Just for fun, edit the index.py to change the name “Chuck” to your own name and press Refresh in
the browser to verify our updates.

Watching the Log


You can watch the internal log of the actions that the web server is performing when you are
interacting with your application in the browser. Select your application in the Launcher and press
the Logs button to bring up a log window:
Each time you press Refresh in your browser – you can see it retrieving the output with a
GET request.

Dealing with Errors


With two files to edit, there are two general categories of errors that you may encounter. If
you make a mistake on the app.yamlfile, the App Engine will not start and your launcher will show
a yellow icon near your application:

To get more detail on what is going wrong, take a look at the log for the application: In this

instance–them is take is m is G indenting the last line in the app.yaml.

If you make a syntax error in the index.py file, a Python trace back error will appear in
your browser. The error you need to see is likely to be the last few lines of the output – in this
case I made a Python syntax error online one of our one G line application.

Reference: http://en.wikipedia.org/wiki/Stack_trace

When you make am I stake in the app.yamlfile–you must the fix them is take and attempt to
start the application again.

If you make is take in a file like index.py, you can simply fix the file and press refresh in your
browser–there is no need to restart the server.

8
Shutting Down the Server
To shut down the server, use the Launcher, select your application and press the
Stop button.

RESULT:
Thus the Install Google App Engine, create hello world app, and other simple web
applications using Python successfully executed.

9
Ex .No: 4 USE GAE LAUNCHER TO LAUNCH THE WEB APPLICATIONS.

AIM:

To use GAE (Google App Engine) launcher to launch web application.

PROCEDURE:

Step 1-Creating a Google Cloud Platform project

To use Google's tools for your own site or app, you need to create a new project on Google Cloud
Platform. This requires shaving a Google account.

1. Go to the AppEngine dashboard on the Google Cloud Platform Console and press the Create
button.
2. If you’ve not created a project before, you'll need to select whether you want to receive email
updates or not, agree to the Terms of Service, and then you should be able to continue. 3. Enter a
name for the project, edit your projected and note it down. For this tutorial, the following values
are used:
a. Project Name :GAE Sample Site Project ID:gaesamplesite
4. Click the Create button not create your project.

Step2-Creating an application

Each Cloud Platform project can contain one AppEngine application. Let's prepare an app for
our project.

We'll need a sample application to publish. If you've not got one to use, download and unzip this
sample app.

1. Have a look at the sample application's structure - the website folder contains your website
content and app.yamlis your application configuration file.
2. Your website content must go inside the website folder, and its land ing page must be called
index.html, but apart from that it can take whatever form you like.
3. The app.yaml file is a configuration file that tells App Engine how to map URLs to your
static files. You don' t need to edit it.

Step3-Publishing your application

1. Now that we've got our project made and sample app files collected together, let's publish our app.
2. Open Google Cloud Shell.
3. Drag and drop the sample-app folder into the left pane of the code editor. 4. Run the
following in the command line to select your project: Gcloudconfig set project gae sample site
5. Then run the following command to go to your app's directory: cdsample-app 6.
You are now ready to deploy your application, i.e.upload your app to App Engine:
Gcloudappdeploy
7. Enter a number to choose their gion where you want your application located.
8. Enter Y to confirm.
9. Now navigate your browser to your - project- id. appspot.com to see your website online.

10
For example, for the projected gae samplesite, goto gaesamplesite.appspot.com.

SOURCE:

<!DOCTYPEhtml>
<html>
<head>
<title>MYPROJECT</title>
<style>ul{
list-style-type: none;padding:0;
margin: 0; overflow:hidden;
background-color:#333;
}
li{
float:left;
}
lia{
display:block;color:white; padding: 14px16px;text-align: center;text-
decoration:none; }
lia:hover{
background-color:#111;
}
.active{
background-color:#4CAF50;
}
</style>
</head>
<bodystyle="background-color:powderblue;">
<palign=center>
<h1align=centerstyle="color:darkblue;">EverGreen</h1>
</p>
<ul>
<li>
<aclass:"active"href="#home">Home</a>
</li>
<li>
<ahref="#aboutus">Aboutus</a>
</li>
<li>
<ahref="#product">Product</a>
</li>
<li>
<ahref="#contact">Contact</a>
</li>
</ul>
<br>

11
<imgsrc="https://specials
images.forbesimg.com/imageserve/1141999659/960x0.jpg?fit=scale"width=1350pxheight=450px>
< /body></html>

RESULT:

Thus the use GAE (GoogleAppEngine) launcher to launch web application has been executed
successfully.

12
Ex No: 5 Simulate a cloud scenario using CloudSim and run a scheduling
algorithm that is not present in CloudSim

AIM:
To simulate a cloud scenario using CloudSim and run a scheduling algorithm that is not present
in CloudSim.

PROCEDURE:

Steps to use CloudSim in Eclipse

Step1: Install java

Step2:Install Eclipse

CloudSim is written in Java. The knowledge you need to use CloudSim is basic Java
programming and some basics about cloud computing. Knowledge of programming IDEs such
as Eclipse or Net Beans is also helpful. It is a library and, hence, CloudSim does not have to
be installed. Normally, you can unpack the downloaded package in any directory, add it to the
Java class path and it is ready to be used. Please verify whether Java is available on your
13
system.

Step3: To use CloudSim in Eclipse

1. Download CloudSim install able files

From https://code.google.com/p/cloudsim/downloads/listandunzip

2. Open Eclipse
3. Create a new Java Project: File->New

4. Import an unpacked CloudSim project into the new Java Project

5. The first step is to initialize the Cloud Sim package by initializing the CloudSim library
,as Follows:

CloudSim.init (num_user,calendar,trace_flag)

1. Data centers are the resource providers in CloudSim; hence, creation of data centers is a
second step. To create Data center, you need the Data center Characteristic s object that
stores the properties of a data centre such as architecture, OS, list of machines, allocation
policy that covers the time or space shared, the time zone and its price:

Data center data center 9883 = new Datacenter (name, characteristics, new VmAllocation
Policy Simple (hostList)

2. The third step is to create a broker : Data center Broker broker = create Broker();

3. The fourth step is to create one virtual machine unique ID of the VM, userId ID of
theVM’s owner, mips, number Of Pes amount of CPUs, amount of RAM, amount of
bandwidth, amount of storage, virtual machine monitor, and cloudlet Scheduler policy for
cloudlets : Vmvm = new

Vm (vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new Cloudlet Scheduler Time
Shared())
14
4. Submit the VMlist to the broker : broker . submit Vm List (vmlist)
5. Create a cloud let with length, file size, output size, and utilization model:

Cloudletcloudlet=newCloudlet (id, length, pesNumber, fileSize, outputSize, utilization


Model, utilization Model,

6. Submit the cloudlet list to the broker: broker.submitCloudletList(cloudletList) 7. Start the

simulation: CloudSim.StartSimulation()

15
RESULT:

Thus Simulation of a cloud scenario using CloudSim and run a scheduling algorithm
that is not present in CloudSim was successfully executed.

16
Ex No: 6 Find a procedure to transfer the files from one virtual machine to another
virtual machine

AIM:
To find a Procedure to transfer files from one VM to another VM inVirtual Box.

PROCEDURE:
A shared folder is a folder which makes its files available on both the guest machine
and the host machine at the same time. Creating a shared folder between the guest and the host
allows you to easily manage files which should be present on both machines. The course virtual
machines are ready to use shared folders right away, but if you are using the virtual machine
on your personal computer you will need to specify which folder to use as shared storage.

Shared Folders on SCS Lab Computers using Course VMs


If you are using a course VM on a lab computer, it is likely that a shared folder has
already been setup for you. On the desktop of your course VM you should notice a folder titled
Shared Folders. Inside of this you will find any folders that have been shared between the
course VM and lab computers. You should see two folders that have already been configured
for you: Z_DRIVE and Temp. Z_DRIVE gives you access to your Windows Account Z:\ drive.
This is storage that is persistent to your SCS account and available as a network drive on the
lab computers. Temp gives you access to the folder found at D:\temp on the lab computer.
Files stored in this folder are local to the machine, meaning that they can be accessed faster,
but will delete from the system when you log out. If you are working with data that you will
need to use again, use the Z_DRIVE for your shared folder. If you need faster read/write speed,
use the Temp folder, but remember to back up your files or they will be deleted when you log
off the computer.
Shared Folders on Personal Computers:
If you are using your own personal machine, you will need to configure Virtual Box to
look in the right place for your shared files. First, click on the guest machine you intend to
share files with. From there, you can select the guest Settings and navigate to Shared Folders
on the left side menu. To create a new shared folder, either clicks the New Folder icon on the
right menu or right clicks the empty list of shared folders and click Add Shared Folder. From
here, there are six options.
∙ Folder Path: The folder name on the host machine. Click the drop down menu and
navigate to the folder you would like to share.
∙Folder Name: This is then ame of the folder asit will appear on the guest machine.
∙Read-Only: If you check read-only, the guest machine will be unable to write changes to the
folder. This is valuable when you only want to send files to the virtual machine, but do not
want to risk having the files modified by the guest.
.Auto-Mount: When any external storage is connected to a computer it must be mounted in
order to be used. It is recommended that you turn on auto-mounting, unless you are familiar
with the process of mounting a drive yourself.

17
∙Mount Point: Unless you already know about mount points, leave this blank.
∙Make Permanent: If you check this, the shared folder will be a permanent machine folder.
If it is not checked, the folder will not be shared after a shutdown.
∙ On the course virtual machines, when you load into the desktop, you should see a folder
labeled Shared Folders. In there you will see any folders that are currently mounted and being
shared.
Dragging and Dropping Files in VirtualBox:
If you only need to transfer a few files quickly, you can simply drag and drop the files
in. On the top bar of the running guest machine, click on Devices > Drag and Drop and make
sure that Bidirectional is selected. This means that you will be able to drag files from the host
to the guest and from the guest to the host. Once bidirectional drag and drop is checked, you
should be able to begin dragging and dropping files. You can also drag files from the guest
machine into the host. To do this, simply open the file browser on the host to where you would
like to drop the files and drag the files from the virtualmachine into the file browser of the host.
File transfers should be pretty quick; if the virtual machine seems stuck when transferring,
simply cancel the transfer and try again.

GUESTOS:

HOST OS:

RESULT:

Thus transfer files from one VM to another VM in VirtualBox were successfully


executed.
18
Ex No: 7 Install Hadoop single node cluster and run simple applications like wordcount.

AIM:
To install Hadoop single node cluster and simple application like word count.

PROCEDURE:

Prerequisite:
To install Hadoop, you should have Java version 1.8 in your system. Check your java version
through this command on command prompt Download the file according to your operating system.
Keep the java folder directly under the local disk directory (C:\Java\jdk1.8.0_152) rather than in
Program Files(C:\ProgramFiles\Java\jdk1.8.0_152)as it can create errors after wards.

After downloading java version1.8, download Hadoop version3.1

Setup System Environment Variables

∙ Open control panel to edit the system environment variable

∙ Create a new user variable. Put the Variable_name as HADOOP_HOME and Variable_value as
the path of the bin folder where you extracted Hadoop.

∙ Likewise, create a new user variable with variable name as JAVA_HOME and variable value as
the path of the bin folder in the Java directory.

∙ Now we need to set Hadoop bin directory and Java bin directory path in system variable
path. Edit Path in system variable

∙ Click on New and add the bin directory path of Hadoop and Javainit.

Configurations
Now we need to edit some files located in the Hadoop directory of the etc folder where
we installed Hadoop. The files that need to be edited have been highlighted.

1. Edit the file core-site.xml in the hadoop directory. Copy this xml property in the
configuration in the file.
/span>configuration>
/span>property>span>name>fs.defaultFS/span>/
name
span>value>hdfs://localhost:9000</value>
/span>/property>
/span>/configuration>

2. Edit map red-site.xml and copy this property in the configuration /span>
configuration> /span>property>
/span>name>mapreduce.framework.name/span>/name>
/span>value>yarn/span>/value>

19
/span>/property>
/span>/configuration>

3. Create a folder ‘data’ in the hadoop directory


Create a folder with the name ‘data node’ and a folder ‘name node’ in this data
directory 4. Edit the file hd fs-site.xml and add below property in the configuration

Note: The path of name node and data node across value would be the path of the data node and name
node folders you just created.

/span>configuration>
/span>property>
/span>name>dfs.replication/span>/name>
/span>value>1/span>/value>
/span>/property>
/span>property>
/span>name>dfs.namenode.name.dir/span>/name
/span>value>C:\Users\hp\Downloads\hadoop-3.1.0\hadoop
3.1.0\data\namenode/span>/value>
/span>/property>
/span>property>
/span>name>dfs.datanode.data.dir/span>/name>
/span>value>C:\Users\hp\Downloads\hadoop-3.1.0\hadoop
3.1.0\data\datanode/span>/value>
/span>/property>
/span>/configuration>

5. Edit the file yarn-site.xml and add below property in the configuration

/span>configuration>
/span>property>
/span>name>yarn.nodemanager.aux-services/span>/name>
/span>value>mapreduce_shuffle/span>/value>
/span>/property>
/span>property>
/span>name>yarn.nodemanager.auxservices.mapreduce.shuffle.class/span>/name
> /span>value>org.apache.hadoop.mapred.ShuffleHandler/span>/value>
/span>/property>
/span>/configuration>

Do it hadoop-env.cmd and replace %JAVA_HOME% with the path of the java folder where your
jdk 1.8is installed

Hadoop needs windows OS specific files which do not come with default download of hadoop. To
include those files, replace the bin folder in Hadoop directory with the bin folder
∙ Download it as zip file. Extract it and copy the bin folder in it. If you want to save the old bin folder,
20
rename it like bin_old and paste the copied bin folder in that directory.

∙ Check whether hadoop is successfully installed by running this command on cmd-Hadoop version

∙ Since it doesn’t throw error and successfully shows the hadoop version, that means hadoop is
successfully installed in the system.

For mat the NameNode

For matting the Name Node is done once when hadoop is installed and not for running hadoop file
system, else it will delete all the data in side HDFS.
Run this command- Hdfs name node–format. It would appear something like this–

Now change the directory in cmd to s bin folder of hadoop directory with this command, (Note: Make
sure you are writing the path as per your system)

Cd C:\Users\hp\Downloads\hadoop-3.1.0\hadoop-3.1.0\sbin

Start name node and data node with this command– start-dfs.cmd

Two more cmd windows will open for Name Node and DataNode Now start yarn through
this command -start-yarn.cmd

Two more windows will open, one for yarn resource manager and one for yarn node manager.

Note: Make sure all the 4 Apache Hadoop Distribution windows are up on running. If they are
not running, you will see an error or a shutdown message. In that case, you need to debug the
error. To access information about resource manager current jobs, successful and failed jobs.

21
To check the details about the hdfs (name node and data node)

Working with HDFS


I will be using a small text file in my local file system. To put it in HDFS using hdfs command
line tool. I will create a directory named ‘sample’ in my hadoop directory using the following
command-hdfsdfs–mkdir/sample

Then I will copy a text file named ‘potatoes’ from my local file system to this folder that I
just created in hdfs using copy From Local command-
hdfsdfs-copyFromLocalC:\Users\hp\Downloads\potatoes.txt/sample
To verify if the file is copied to the folder, I will use ‘ls’ command by
specifying the folder name which will read the list of files in that folder–
hdfsdfs–ls/sample

To view the contents of the file we copied, I will use cat command

hdfsdfs–cat/sample/potatoes.txt

To Copy file from hdfs to local directory, I will use get command–

hdfsdfs-get/sample/potatoes.txtC:\Users\hp\Desktop\priyanka

Hadoop Map Reduce can be used to perform data processing activity. However,
it possessed limitations due to which frame works like Spark and Pig emerged and
have gained popularity. 200 lines of Map Reduce code can be written with less
than 10 lines of Pig code. Hadoop has various other components in its ecosystem
like Hive, Sqoop, Oozie, and HBase. You can down load these software

22
RESULT:
Thus installation of Hadoop single node cluster and simple application like
word count has executed successfully.

23
Ex No: 8 Creating and Executing your first container using Docker

Aim:
To create and execute first container using docker.

Procedure:

Step 1: Run your first container¶


We are going to use the Docker CLI to run our first container.

1. Open a terminal on your local computer


2. Run docker container run -t ubuntu top
Use the docker container run command to run a container with the ubuntu image using
the top command. The -t flags allocate a pseudo-TTY which we need for the top to
work correctly.
$ docker container run -it ubuntu top
Unable to find image 'ubuntu:latest' locally
Latest: Pulling from library/ubuntu
aafe6b5e13de: Pull complete
0a2b43a72660: Pull complete
18bdd1e546d2: Pull complete
8198342c3e05: Pull complete
f56970a44fd4: Pull complete
Digest:
sha256:f3a61450ae43896c4332bda5e78b453f4a93179045f20c8181043b26b5e790
28
Status: Downloaded newer image for ubuntu: latest
3. Inspect the container with docker container exec
root@b3ad2a23fab3:/# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 20:34 ? 00:00:00 top
root 17 0 0 21:06 ? 00:00:00 bash
root 27 17 0 21:14 ? 00:00:00 ps -ef
4. Clean up the container running the top processes by typing: <ctrl>-c, list all
containers and remove the containers by their id.

Step 2: Run Multiple Containers¶


1. Explore the Docker Hub
In Step 2 of this lab, we will start a couple of containers using some verified images
from the Docker Hub: nginx web server, and mongo database.
2. Run an Nginx server
Let's run a container using the official Nginx image from the Docker Hub.

$ docker container run --detach --publish 8080:80 --name nginx


24
nginx Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
36a46ebd5019: Pull complete
57168433389f: Pull complete
332ec8285c50: Pull complete
Digest:
sha256:c15f1fb8fd55c60c72f940a76da76a5fccce2fefa0dd9b17967b9e40b035531
6 Status: Downloaded newer image for nginx:latest
5e1bf0e6b926bd73a66f98b3cbe23d04189c16a43d55dd46b8486359f6fdf04
8 3. Access the nginx server on localhost:8080.
4. <!DOCTYPE html>
5. <html>
6. <head>
7. <title>Welcome to nginx!</title>
8. <style>
9. body {
10. width: 35em;
11. margin: 0 auto;
12. font-family: Tahoma, Verdana, Arial, sans-serif;
13. }
14. </style>
15. </head>
16. <body>
17. <h1>Welcome to nginx!</h1>
4. If you are using play-with-docker, look for the 8080 link near the top of the page, or if
you run a Docker client with access to a local browser,
5. Run a mongo DB server
Now, run a mongoDB server. We will use the official mongoDB image from the
Docker Hub. Instead of using the latest tag (which is the default if no tag is specified),
we will use a specific version of the mongo image: 4.4.
$ docker container run --detach --publish 8081:27017 --name mongo
mongo:4.4 Unable to find image mongo:4.4 locally
4.4: Pulling from library/mongo
d13d02fa248d: Already exists
bc8e2652ce92: Pull complete
3cc856886986: Pull complete
c319e9ec4517: Pull complete
b4cbf8808f94: Pull complete
cb98a53e6676: Pull complete
f0485050cd8a: Pull complete
ac36cdc414b3: Pull complete
61814e3c487b: Pull complete
523a9f1da6b9: Pull complete
3b4beaef77a2: Pull complete

Digest:
sha256:d13c897516e497e898c229e2467f4953314b63e48d4990d3215d876ef9d1fc
Status: Downloaded newer image for mongo:4.4
d8f614a4969fb1229f538e171850512f10f490cb1a96fca27e4aa89ac082eba
6. Access localhost:8081 to see some output from mongo.
25
curl localhost:8081
which will return a warning from MongoDB,
It looks like you are trying to access MongoDB over HTTP on the native driver
port. 7. If you are using play-with-docker, look for the 8080 link near the top of the page.
8. Check your running containers with docker container ls

Step 3: Clean Up
1. First get a list of the containers running using docker container ls.
2. Next, run docker container stop [container id] for each container in the list. You can
also use the names of the containers that you specified before.
3. Remove the stopped containers

Result:
Thus the container created and executed with docker

26
Ex No: 9 Run a container from Docker hub

Aim:
To run a container from docker hub

Procedure:
Step 1: Sign up for a Docker account
Start by creating a Docker ID
Step 2: Create your first repository

To create a repository:

1. Sign in to Docker Hub.


2. Select Create a Repository on the Docker Hub welcome page.

3. Name it <your-username>/my-private-repo.

4. Set the visibility to Private.


5. Select Create.

Step 3: Download and install Docker Desktop

1. You need to download Docker Desktop to build, push, and pull container
images.

2. Download and install Docker Desktop.

3. Sign in to Docker Desktop using the Docker ID you created in step one.
Step 4: Pull and run a container image from Docker Hub

docker pull hello-world


Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest:
sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac66dca625

Status: Downloaded newer image for hello-world:latest

docker.io/library/hello-world:latest

27
docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

Step 5: Build and push a container image to Docker Hub from your

computer

1. Start by creating a Dockerfile to specify application


2. Run docker build -t <your_username>/my-private-repo . to build your Docker image.
3. Run docker run <your_username>/my-private-repo to test your Docker image locally.
4. Run docker push <your_username>/my-private-repo to push your Docker image to
Docker Hub.

Result:

Thus a container can run from Docker Hub

28
29

You might also like