0% found this document useful (0 votes)
48 views

Cloud Computing Lab Manual

LAB MANUAL

Uploaded by

SARITHA PS AI&DS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Cloud Computing Lab Manual

LAB MANUAL

Uploaded by

SARITHA PS AI&DS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 50

DHANALAKSHMI

SRINIVASAN COLLEGE OF
ENGINEERING
(APPROVED BY AICTE, NEWDELHI & AFFILIATED TO ANNA UNIVERSITY, CHENNAI)

NH-47, PALAKKAD MAIN ROAD, NAVAKKARAI POST, NEAR NANDHI TEMPLE,


COIMBATORE 641-105

CCS335-CLOUD
COMPUTING LAB
MANUAL
DHANALAKSHMI
SRINIVASAN COLLEGE OF
ENGINEERING
(Approved by AICTE, NewDelhi & Affiliated to Anna University, Chennai)
Nh-47, Palakkad Main Road, Navakkarai Post, Near Nandhi Temple, Coimbatore-641-105

DEPARTMENT OF
ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
[CCS335-CLOUD COMPUTING LABORATORY]

CCS335-CLOUDCOMPUTING
LAB MANUAL

PREPARED BY, VERIFIED BY,

HOD, AI&DS
LIST OF EXPERIMENTS
1. Install Virtualbox / VMware Workstation with different flavours of linux or
windows OS on top of windows7 or 8.

2. Install a C compiler in the virtualmachine created using virtual boxand


execute Simple Programs

3. Install Google App Engine. Create hello world app and other simple webapplications
using python/java

4. Use GAE launcher to launch the web applications

5. Simulate a cloud scenario using CloudSim and run a schedulingalgorithm that is


not present in CloudSim

6. Find a procedure to transfer the files from onevirtual machine to another virtual
machine

7. Install Hadoop single node cluster and run simple applications like wordcount.

8. Creating and executing your first container using Docker

9. Run a Container from Docker Hub


EX NO.: 1

DATE :
Install VirtualBox / VMware Workstation with different flavors of Linux or
windows OS on top of windows7 or 8.

Aim:
To Install VirtualBox / VMware Workstation with different flavors of Linux or windows OS on top of
windows7 or 8.

PROCEDURE:

Steps to install Virtual Box:


1. Download the Virtual box exe and click the exe file…and select next button..

2. Click the next button..


3. Click the next button

4. Click the YES button..


5. Click the install button…

6. Then installation was completed..the show virtual box icon on desktop screen….
Steps to import Open nebula sandbox:
1. Open Virtual box
2. File import Appliance
3. Browse OpenNebula-Sandbox-5.0.ova file
4. Then go to setting, select Usb and choose USB 1.1
5. Then Start the Open Nebula
6. Login using username: root, password:opennebula
Steps to create Virtual Machine through open nebula
1. Open Browser, type localhost:9869
2. Login using username: one admin, password: open nebula
3. Click on instances, select VMs then follow the steps to create Virtual machine
a. Expand the + symbol
b. Select user one admin
c. Then enter the VM name, no. of instance, cpu.
d. Then click on create button.
e. Repeat the steps the C,D for creating more than one VMs.
RESULT:
Thus, the procedure to run the virtual machine of different configuration.
EX.NO.:2
DATE:
Install a C compiler in the virtual machine created using virtual box and
execute Simple Programs

Aim
: To Install a C compiler in the virtual machine created using virtual box and
execute Simple Programs`

PROCEDURE:

Steps to import .ova file:


1. Open Virtual box
2. File import Appliance
3. Browse ubuntu_gt6.ova file
4. Then go to setting, select Usb and choose USB 1.1
5. Then Start the ubuntu_gt6
6. Login using username: dinesh, password:99425.
Steps to run c program:

1. Open the terminal


2. Type cd /opt/axis2/axis2-1.7.3/bin then press enter
3. gedit hello.c
4. gcc hello.c
5. ./a.out

1. Type cd /opt/axis2/axis2-1.7.3/bin then press enter

2. Type gedit first.c


3. Type the c program

4. Running the C program


5. Display the output:

APPLICATIONS:
Simply running all programs in grid environment.

RESULT:

Thus, the simple C programs executed successfully.


EX NO.:3
DATE :
Install Google App Engine. Create hello world app and other simple web
applications using python/java.

Aim
: To Install Google App Engine. Create hello world app and other simple web
applications using python/java.
PROCEDURE:

1. Install Google Plugin for Eclipse


Read this guide – how to install Google Plugin for Eclipse. If you install the Google App Engine Java SDK
together with “Google Plugin for Eclipse“, then go to step 2, Otherwise, get the
Google App Engine Java SDK and extract it.

2. Create New Web Application Project


In Eclipse toolbar, click on the Google icon, and select “New Web Application Project…”

Figure – New Web Application Project

Figure – Deselect the “Google Web ToolKit“, and link your GAE Java SDK via the “configure
SDK” link.
Click finished, Google Plugin for Eclipse will generate a sample project automatically.

3. Hello World
Review the generated project directory.
Nothing special, a standard Java web project structure.

HelloWorld/ src/
...Java source code...
META-INF/
...other configuration... war/
...JSPs, images, data files...
WEB-INF/
...app configuration...
lib/
...JARs for libraries...
classes/
...compiled classes...
Copy
The extra is this file “appengine-web.xml“, Google App Engine need this to run and deploy the application.

File : appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>


<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application></application>
<version>1</version>

<!-- Configure java.util.logging -->


<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

</appengine-web-app>

Copy

4. Run it local
Right click on the project and run as “Web Application“.

Eclipse console :

//...
INFO: The server is running at http://localhost:8888/
30 Mac 2012 11:13:01 PM com.google.appengine.tools.development.DevAppServerImpl start INFO: The
admin console is running at http://localhost:8888/_ah/admin
Copy
Access URL http://localhost:8888/, see output
and also the hello world servlet – http://localhost:8888/helloworld

5. Deploy to Google App Engine


Register an account on https://appengine.google.com/, and create an application ID for your web application.

In this demonstration, I created an application ID, named “mkyong123”, and put it in appengine web.xml.

File : appengine-web.xml -

<?xml version="1.0" encoding="utf-8"?>


<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>mkyong123</application>
<version>1</version>

<!-- Configure java.util.logging -->


<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>

</appengine-web-app>
To deploy, see following steps:

Figure 1.1 – Click on GAE deploy

oy button on the
toolbar.
Figure 1.2 – Sign in with your Google account and click on the Deploy button.
Figure 1.3 – If everything is fine, the hello world web application will be deployed to this URL –
http://mkyong123.appspot.com/

RESULT:

Thus, the simple application was created successfully.


EX. NO.:4
DATE:
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.
Steps
:

How to use CloudSim in 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 NetBeans 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 classpath and it is ready to be used. Please verify whether Java is available
on your system.

To use CloudSim in Eclipse:


1. Download CloudSim installable files
from https://code.google.com/p/cloudsim/downloads/list and unzip
2. Open Eclipse
3. Create a new Java Project: File -> New
4. Import an unpacked CloudSim project into the new Java Project
The first step is to initialise the CloudSim package by initialising the CloudSim
library, as follows
CloudSim.init(num_user, calendar, trace_flag)
5. Data centres are the resource providers in CloudSim; hence, creation of data centres is a
second step. To create Datacenter, you need the Data center Characteristics object that stores
the properties of a data centre such as architecture, OS, list of machines, allocation policy that
covers the time or spaceshared, the time zone and its price:
Datacenter datacenter9883 = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList), s
6. The third step is to create a broker:
DatacenterBroker broker = createBroker();
7. The fourth step is to create one virtual machine unique ID of the VM, userId ID of the
VM’s owner, mips, number Of Pes amount of CPUs, amount of RAM, amount of bandwidth,
amount of storage, virtual machine monitor, and cloudletScheduler policy for cloudlets:
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new
CloudletSchedulerTimeShared())
8. Submit the VM list to the broker:
broker.submitVmList(vmlist)
9. Create a cloudlet with length, file size, output size, and utilisation model:
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize, outputSize,
utilizationModel, utilizationMode
10. Submit the cloudlet list to the broker:
broker.submitCloudletList(cloudletList) Sample
Output from the Existing Example:
Starting
CloudSimExample1...
Initialising...
Starting CloudSim version
Datacenter_0 is starting...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>null
Broker is
starting... Entities
started.
: Broker: Cloud Resource List received with 1 resource(s)
0.0: Broker: Trying to Create VM #0 in Datacenter_0
: Broker: VM #0 has been created in Datacenter #2, Host #0 0.1: Broker:
Sending cloudlet 0 to VM #0
: Broker: Cloudlet 0 received
: Broker: All Cloudlets executed. Finishing
...................... 400.1: Broker: Destroying
VM #0
Broker is shutting down... Simulation:
No more future events
CloudInformationService: Notify all CloudSim entities for shutting down.
Datacenter_0 is shutting down...
Broker is shutting
down......Simulation
completed. Simulation
completed.
========== OUTPUT ==========
Cloudlet ID STATUS Data center ID Finish VM ID Time Start Time
Time 0 SUCCESS 2 0 400
0.1 400.1
*****Datacenter: Datacenter_0*****
User id
Debt
3 35.6

CloudSimExample1 finished!

RESULT:

The simulation was successfully executed.


EX.NO.:5
DATE:
Use GAE launcher to launch the web applications.

Aim:
To Use GAE launcher to launch the web applications.

PROCEDURE:

Making your First Application

Now you need to create a simple application. We could use the “+”option to have the
launcher makeusanapplication– but instead we will doit by handto 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:\Documents and Settings\csev\Desktop\apps


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

C:\ Documents and Settings \csev\Desktop\apps\ae--01--trivial


Using a text editor such as JEdit (www.jedit.org), create a file called app.yaml in the ae--01--trivial
folder with the following contents:
application: ae-01-trivial
version: 1
runtime: python api_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 'Content-Type: text/plain'
print ' '
print 'Hello there Chuck'
Then start the Google App Engine Launcher 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 momentsyour 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:8080 into 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 your updates.

Watching the Log

You can watch the internal log of the actions that the webserver is performing when
you are interacting with your application in the browser. Select your applicationin 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 – the mistake is mis-•‐indenting the last line in the app.yaml (line 8).
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 on line one of our one--‐line application.
Reference: http://en.wikipedia.org/wiki/Stack_trace
When you make a mistake in the app.yaml file – you must the fix the mistake and attempt
to start the application again.
If you make a mistake 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.

Shutting Down the Server


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

RESULT:

Thus, the GAE web applications was created.


EX.NO:6
DATE: Find a procedure to transfer the files from one virtual machine
to another virtual machine.

Aim
: To Find a procedure to transfer the files from one virtual machine
to another virtual machine.

PROCEDURE:

1. You can copy few (or more) lines with copy & paste mechanism.
For this you need to share clipboard between host OS and guest OS, installing Guest
Addition on both the virtual machines (probably setting bidirectional and restarting them).
You copy from guest OS in the clipboard that is shared with the host OS.
Then you paste from the host OS to the second guest OS.
2. You can enable drag and drop too with the same method (Click on the machine,
settings, general, advanced, drag and drop: set to bidirectional )
3. You can have common Shared Folders on both virtual machines and use one of
the directory shared as buffer to copy.
Installing Guest Additions you have the possibility to set Shared Folders too. As you put a
file in a shared folder from host OS or from guest OS, is immediately visible to the other.
(Keep in mind that can arise some problems for date/time of the files when there are
different clock settings on the different virtual machines).
If you use the same folder shared on more machines you can exchange files directly copying
them in this folder.
4. You can use usual method to copy files between 2 different computer with client-server
application. (e.g. scp with sshd active for linux, winscp... you can get some info about SSH
servers e.g. here)
You need an active server (sshd) on the receiving machine and a client on the sending
machine. Of course you need to have the authorization setted (via password or, better,
via an automatic authentication method).
Note: many Linux/Ubuntu distribution install sshd by default: you can see if it is running
with pgrep sshd from a shell. You can install with sudo apt-get install opens sh-server.
5. You can mount part of the file system of a virtual machine via NFS or SSHFS
on the other, or you can share file and directory with Samba. You may find
interesting the article Sharing files between guest and host without VirtualBox
shared folders with detailed step by step instructions.
You should remember that you are dialing with a little network of machines with different
operative systems, and in particular:

 Each virtual machine has its own operative system running on and acts as a
physical machine.
 Each virtual machine is an instance of a program owned by an user in the hosting
operative system and should undergo the restrictions of the user in the hosting OS.
E.g Let we say that Hastur and Meow are users of the hosting machine, but they did not
allow each other to see their directories (no read/write/execute authorization). When each
of them run a virtual machine, for the hosting OS those virtual machine are two normal
programs owned by Hastur and Meow and cannot see the private directory of the other
user. This is a restriction due to the hosting OS. It's easy to overcame it: it's enough to give
authorization to read/write/execute to a directory or to chose a different directory in which
both users can read/write/execute.
 Windows likes mouse and Linux fingers. :-)
I mean I suggest you to enable Drag & drop to be cosy with the Windows machines and the
Shared folders or to be cosy with Linux.
When you will need to be fast with Linux you will feel the need of ssh-keygen and
to Generate once SSH Keys to copy files on/from a remote machine without writing password anymore. In
this way it functions bash auto-completion remotely too!

PROCEDURE:
Steps:
1. Open Browser, type localhost:9869
2. Login using username: one admin, password: open nebula
3. Then follow the steps to migrate VMs
a. Click on infrastructure
b. Select clusters and enter the cluster name
c. Then select host tab, and select all host
d. Then select Vnets tab, and select all vnet
e. Then select datastores tab, and select all datastores
f. And then choose host under infrastructure tab
g. Click on + symbol to add new host, name the host then click on create.
4. on instances, select VMs to migrate then follow the steps
a. Click on 8th icon ,the drop down list display
b. Select migrate on that ,the popup window display
c. On that select the target host to migrate then click on migrate.
Before migration
Host:SACET

Host:one-sandbox
After Migration:

Host:one-sandbox
Host:SACET

APPLICATIONS:
Easily migrate your virtual machine from one pc to another.

RESULT:
Thus, the file transfer between VM was successfully completed.
EX NO.:7
DATE :

Install Hadoop single node cluster and run simple


applications like wordcount.

Aim:
To Install Hadoop single node cluster and run simple
applications like wordcount.

PROCEDURE:

Install Hadoop

Step 1: Download the Java 8 Package. Save this file in your home directory.

Step 2: Extract the Java Tar File.

Command: tar -xvf jdk-8u101-linux-i586.tar.gz

Fig: Hadoop Installation – Extracting Java Files

Step 3: Download the Hadoop 2.7.3 Package.

Command: wget https://archive.apache.org/dist/hadoop/core/hadoop-2.7.3/hadoop-


2.7.3.tar.gz

Fig: Hadoop Installation – Downloading Hadoop

Step 4: Extract the Hadoop tar File.

Command: tar -xvf hadoop-2.7.3.tar.gz


Fig: Hadoop Installation – Extracting Hadoop Files Step

5: Add the Hadoop and Java paths in the bash file (.bashrc). Open.
bashrc file. Now, add Hadoop and Java Path as shown below.

Command: vi .bashrc

Fig: Hadoop Installation – Setting Environment Variable


Then, save the bash file and close it.

For applying all these changes to the current Terminal, execute the source command.
Command: source .bashrc

Fig: Hadoop Installation – Refreshing environment variables

To make sure that Java and Hadoop have been properly installed on your system and can be
accessed through the Terminal, execute the java -version and hadoop version commands.

Command: java -version


Fig: Hadoop Installation – Checking Java Version
Command: hadoop version

Fig: Hadoop Installation – Checking Hadoop Version

Step 6: Edit the Hadoop Configuration files.

Command: cd hadoop-2.7.3/etc/hadoop/

Command: ls

All the Hadoop configuration files are located in hadoop-2.7.3/etc/hadoop directory as you can
see in the snapshot below:

Fig: Hadoop Installation – Hadoop Configuration Files


Step 7: Open core-site.xml and edit the property mentioned below inside configuration
tag:

core-site.xml informs Hadoop daemon where NameNode runs in the cluster. It contains
configuration settings of Hadoop core such as I/O settings that are common to HDFS &
MapReduce.

Command: vi core-site.xml

Fig: Hadoop Installation – Configuring core-site.xml

1
<?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?
3 >
4 <configuration>
5 <property>
6 <name>fs.default.name</name>
7 <value>hdfs://localhost:9000</value>
</property>
</configuration>
Step 8: Edit hdfs-site.xml and edit the property mentioned below inside
configuration tag:

hdfs-site.xml contains configuration settings of HDFS daemons (i.e. NameNode, DataNode,


Secondary NameNode). It also includes the replication factor and block size of HDFS.

Command: vi hdfs-site.xml
Fig: Hadoop Installation – Configuring hdfs-site.xml

1
2 <?xml version="1.0" encoding="UTF-8"?>
3 <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
4 <property>
5 <name>dfs.replication</name>
6 <value>1</value>
7 </property>
8 <property>
9 <name>dfs.permission</name>
<value>false</value>
10 </property>
11 </configuration>

Step 9: Edit the mapred-site.xml file and edit the property mentioned below
inside configuration tag:

mapred-site.xml contains configuration settings of MapReduce application like number of JVM


that can run in parallel, the size of the mapper and the reducer process, CPU cores available for a
process, etc.

In some cases, mapred-site.xml file is not available. So, we have to create the mapred- site.xml
file using mapred-site.xml template.

Command: cp mapred-site.xml.template mapred-site.xml

Command: vi mapred-site.xml.

Fig: Hadoop Installation – Configuring mapred-site.xml


1
<?xml version="1.0" encoding="UTF-8"?>
2
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
3 <configuration>
4 <property>
5 <name>mapreduce.framework.name</name>
6 <value>yarn</value>
7 </property>
</configuration>

Step 10: Edit yarn-site.xml and edit the property mentioned below inside
configuration tag:

yarn-site.xml contains configuration settings of Resource Manager and Node Manager like
application memory management size, the operation needed on program & algorithm, etc.

Command: vi yarn-site.xml

Fig: Hadoop Installation – Configuring yarn-site.xml

Step 11: Edit hadoop-env.sh and add the Java Path as mentioned below:
1
2 <?xml version="1.0">
3 <configuration>
4 <property>
5 <name>yarn.nodemanager.aux-services</name>
6 <value>mapreduce_shuffle</value>
7 </property>
<property>
8<name>yarn.nodemanager.auxservices.mapreduce.shuffle.class</ name>
9 <value>org.apache.hadoop.mapred.ShuffleHandler</value>
1 </property>
0
1

hadoop-env.sh contains the environment variables that are used in the script to run Hadoop
like Java home path, etc.
Command: vi hadoop–env.sh

Fig: Hadoop Installation – Configuring hadoop-env.sh Step

12: Go to Hadoop home directory and format the NameNode.

Command: cd

Command: cd hadoop-2.7.3

Command: bin/hadoop namenode -format

Fig: Hadoop Installation – Formatting NameNode

This formats the HDFS via NameNode. This command is only executed for the first time.
Formatting the file system means initializing the directory specified by the dfs.name.dir
variable.

Never format, up and running Hadoop filesystem. You will lose all your data stored in the
HDFS.

Step 13: Once the NameNode is formatted, go to hadoop-2.7.3/sbin directory and start all the daemons.

Command: cd hadoop-2.7.3/sbin

Either you can start all daemons with a single command or do it individually.

Command: ./start-all.sh

The above command is a combination of start-dfs.sh, start-yarn.sh & mr-jobhistory-


daemon.sh

Or you can run all the services individually as below:


Start NameNode:

The NameNode is the centerpiece of an HDFS file system. It keeps the directory tree of all files
stored in the HDFS and tracks all the file stored across the cluster.

Command: ./hadoop-daemon.sh start namenode

Fig: Hadoop Installation – Starting NameNode

Start DataNode:
On startup, a DataNode connects to the Namenode and it responds to the requests from
the Namenode for different operations.

Command: ./hadoop-daemon.sh start datanode

Fig: Hadoop Installation – Starting DataNode

Start ResourceManager:

ResourceManager is the master that arbitrates all the available cluster resources and thus
helps in managing the distributed applications running on the YARN system. Its work
is to manage each NodeManagers and the each application’s ApplicationMaster.

Command: ./yarn-daemon.sh start resourcemanager

Fig: Hadoop Installation – Starting ResourceManager

Start NodeManager:

The NodeManager in each machine framework is the agent which is responsible for
managing containers, monitoring their resource usage and reporting the same to the
ResourceManager.

Command: ./yarn-daemon.sh start nodemanager


– Starting NodeManager

Start JobHistoryServer:

JobHistoryServer is responsible for servicing all job history related requests from client.

Command: ./mr-jobhistory-daemon.sh start historyserver

F
Step 14i: To check that all the Hadoop services are up and running, run the
below cgommand.
:

CoHmmand:
jps
a
d Fig: Hadoop Installation – Checking Daemons
o
o

p
Result:I
nThus, the Hadoop one cluster was installed and simple applications
s
texecuted successfully.
a
l
l
a
t
i
o
n
EX NO.:8
DATE :

Creating and executing your first container using Docker.

Aim:
To Create and execute your first container using Docker.

PROCEDURE:

Steps for Creating and executing your first container using Docker.

o For Ubuntu:
1. Install Docker on Your Machine:
 Update your packages:
 $ sudo apt update
 Install Docker with apt-get:
 $ sudo apt install docker.io
 Verify that Docker is installed correctly:
 $ docker –version

2. Create a Simple Python Program:


o You won’t need to install Python on your computer. Docker will handle it.
3. Write a Dockerfile:
o Create a new directory for your project:
o Create a file named Dockerfile (no file extension) in the same directory as your Python file.
o $ mkdir my-docker-app
o Open Dockerfile in a text editor and add the following lines:
o $ cd my-docker-app
o # Use the official Python image as the base image
o Inside this directory, create a Python file (e.g., app.py) with the following content:
o FROM python:3
o # Set the working directory inside the container
Python
o WORKDIR /app
o ##Copy
app.pythe Python file into the container
o COPY app.py Docker!")
print("Hello, .
o # Run the Python program when the container starts
o CMD ["python", "app.py"
4. Build the Docker Image:
o In the terminal, navigate to your project directory.
o Build the Docker image using the following command:
5. Runothe$Docker
docker Container:
build -t my-docker-app .
o Execute the following command to run your container:
o $ docker run my-docker-app
RESULT:
o You should see the output: “Hello, Docker!”
Thus, Created and executed the first container using Docker.
EX NO. : 9

DATE:

Run a Container from Docker Hub.

AIM:
To write a program to run a container from Docker hub.

PROCEDURE:

To run a container from Docker Hub, you can follow these steps:

1. Search for the Image:


o Open Docker Desktop and select the search option.
o Specify docker/welcome-to-docker in the search bar.

2. Run the Image:


o After finding the image using the search, select “Run.”
o Expand the optional settings.
o In the “Host port,” specify a port (e.g., 8090).
o Select “Run.”

3. Explore the Container:


o You can now access your running container using Docker Desktop or by
visiting localhost:8090 in your web browser1.

Additionally, if you want to create and run your own custom container, follow these steps:

1. Get the Sample Application:


o Clone the repository for the sample application from here or download it.

2. View the Dockerfile:


o A Dockerfile describes what goes into a container. The sample application already contains a
Dockerfile. For your own projects, create your own Dockerfile.
3. Build Your First Image:
o In a terminal, navigate to the project folder containing the Dockerfile.
o Run the following commands to build the image:
o $ cd /path/to/welcome-to-docker/
o $ docker build -t welcome-to-docker .
o The -t flag tags your image with a name (e.g., welcome-to-docker), and the . specifies the
location of the Dockerfile.

4. Run Your Container:


o In Docker Desktop, go to the “Images” tab.
o Next to your image, select “Run.”
o Specify any optional settings (e.g., host port).
o Select “Run.”

5. View the Frontend:


o Access your running container by clicking the link next to it in Docker Desktop or
visiting localhost:8089 in your browser2.

RESULT:
Thus, program to run a container from Docker hub has successfully done.

You might also like