CCS335 CC Record Final
CCS335 CC Record Final
RECORD
Name :
Register No :
Branch :
Year / Sem :
BONAFIDE CERTIFICATE
Register No.
AIM:
To find procedure to run the virtual machine of different configuration and check how
manyvirtual machines can be utilized at particular time.
PROCEDURE:
Step 2: Provide a name for the virtual machine and select the hard disk size for the
virtualmachine. Select the storage size as Dynamically allocated memory size and click
[Link] virtual machine will be created.
1
Step 3: Select the iso file of the virtual OS Ubuntu and click Start.
Step 4: The virtual OS Ubuntu is opened successfully. Now type “gedit” in the searchbox to open text
editor in Ubuntu.
Step 5: Type your desired C program in text editor and save it with the extension (.c).
Step 6: Type “terminal” in the search box to open the command window.
Step 7: Type the necessary commands to compile and run the C program.
2
Installing Windows 7 using Oracle Virtual
Box PROCEDURE:
Step1: Open Oracle virtual box manager and click create new -> virtual machine. Provide and
name for the operating system and select the memory size to be occupied in memory.
Step 2: Select the iso file of the virtual OS Windows7 and click Start.
Step 3: Select the language to use in the Operating System and click Install Now.
3
LOUD COMPUTING LABORATORY
Step 4: Select the type of installation as Custom for new installation and allocate Diskspace
according to your convenience. Click Next to start the installation.
Step 5: After installation the system will be restarted to complete the installation.
4
Step 6: Provide a user name and password(optional) to gain access over the OS.
Step 7: Set the time and date for the new Operating System.
Step 8: Thus the new Operating System Windows7 will be opened as the virtual machine.
5
Viva Questions:
1. What is virtualization?
2. What is the role of a hypervisor?
3. Difference between host OS and guest OS?
4. What is the use of VirtualBox / VMware?
5. Name any two Linux distributions used in virtual machines.
RESULT:
Thus the procedure to run different virtual machines on a single system using
Oracle Virtual Box is studied and implemented successfully.
6
Viva Questions with Answers:
7
[Link] Install a C compiler in the virtual machine created using virtual box and
Date: execute Simple Programs.
AIM:
To find a procedure to use the C compiler in the virtual machine and execute a sample program.
PROCEDURE:
Step 1: Open the virtual machine in which you want to run the C program.
Step 2: The text editor used by the Ubuntu Operating System is the [Link] can be
opened by using the search option by typing gedit in it.
Step 3: Type your desired C program in the text editor and save it as a C file using
theExtension (.c) for C programs.
8
Step 4: Type “terminal” in the search box to open the command window.
Step 5: Type the necessary commands to cmpile and run the C program.
(1). ./[Link] to display the output of the last compiled program.
9
Viva Questions:
1. What is a compiler?
2. Name a C compiler commonly used in Linux.
3. Why do we use GCC in virtual machines?
4. What is the purpose of the gcc command?
5. How do you execute a C program in Linux?
RESULT:
Thus the procedure to use the C compiler in the virtual machine and execute a sample
program is implemented successfully.
10
Viva Questions with Answers :
11
[Link]
Installing Google App Engine. Create a hello world app and other simple web
Date: applications using python/java
AIM:
To Installing and Running the Google App Engine On Windows
PROCEDURE:
Install the latest Cloud SDK
Version(303.0.0) Step1: Download the
Cloud SDK installer.
pid/[Link]", "$env:Temp\[Link]
& $env:Temp\[Link]
Step 2: Launch the installer and follow the prompts. The installer is signed by Google LLC. Cloud
SDK requires Python. Supported versions are 3.5 to 3.7, and 2.7.9 or higher.
The installer will install all necessary dependencies, including the needed Python version. While
Cloud SDK currently uses Python 2 by default, you can use an existing Python installation if
necessary by unchecking the option to 'Install Bundled Python'. .
Note: Cloud SDK uses Python 2 by default, but will soon move to Python 3 (run gcloud topic
startup for exclusions and more information on configuring your Python interpreter to use a
different version). Consider upgrading to Python 3 to avoid disruption in the future.
Step 3: After installation has completed, accept the following options: Start
Cloud SDK Shell
Run gcloud init
OUTPUT:
12
The installer starts a terminal window and runs the gcloud init command
Step 4: The default installation does not include the App Engine extensions required to
deploy an application using gcloud commands. These components can be installed using
the Cloud SDK component manager.
Optional: Enable accessibility features
For a more streamlined screen reader experience, the gcloud command-line tool comes with
an accessibility/screen_reader property.
gcloud config set accessibility/screen_reader true
Percentage progress bars: Progress will be displayed as a percentage, outputted to stderr.
Boxed tables drawn with ASCII characters: Boxed tables are the default output of many
list commands. Instead of being drawn with Unicode, they will be rendered using ascii
characters. Also, consider using the --format flag to define your own format. To enable these
accessibility features, run:
$ gcloud config set accessibility/screen_reader true
Additional resources
Alternate documentation experiences
To search the gcloud CLI reference docs for a keyword or command, use gcloud help.
This runs a search for all commands with help text matching the given argument or
arguments.
To adjust the verbosity level of a command, you can set the gcloud CLI-wide flag --
verbosity with either debug, info, warning, error, critical, or none.
13
For list commands, you can further refine your output by using the --limit flag to set a
maximum number of resources to list. You can also use the --page-size flag to define the
number of resources per page if the service lists output in pages. To sort, use the --sort-
by flag with the relevant field to sort.
To structure and produce more meaningful output, you can use the format, filter and
projection flags to fine-tune your output.
If you'd like to define just the format of your output, use the --format flag to produce a
tabulated or flattened version of your output (for interactive display) or a machine-
readable version of the output (json, csv, yaml, value). To format a list of keys that
select resource data values, use projections.
14
To further refine your output to a criteria you'd like to define, use the -- filter flag.
Filing feedback
To file a bug, provide feedback, or send suggestions, use gcloud feedback to help
improve the gcloud command-line tool experience. This command will open the public
issue tracker in a browser window.
You can also directly log issues using issue tracker. Be sure to toggle the 'Type' field to
reflect the nature of the issue you're filing (Bug, Feature Request, etc.) to help make
responses more efficient.
To enable this property, run:
• Download Google Cloud SDK[Link]
• Login to google account and verify the account with google for the
successful authentication.
• Download webapp2 module from [Link]
• Write down simple hello world python program. import webapp2
class MainPage([Link]) def get(self):
[Link]("Hello World")
Run the gcloud prompt and give Yes option to proceed further. Install gcloud components
using the command gcloud components install cloud-datastore-emulator
15
Viva Questions:
RESULT:
Thus the procedure to use the C compiler in the virtual machine and execute a sample
program is implemented successfully.
16
Viva Questions with Answers:
17
[Link]: 4
Use the GAElauncherto launchthe web applications
Date:
AIM:
To Use GAE launcher to launch the web applications
PROCEDURE:
2. Download, install, and then initialize the Cloud SDK. If you already have
the Cloud SDK installed, run the gcloud components update command
to update to the latest release.
The Cloud SDK provides you the gcloud command-line tooling for
deploying and managing your apps.
Note: Avoid using a package manager such as apt or yum to install the Cloud SDK.
• Flask
• Pyramid
18
• Bottle
• [Link]
• Tornado
• www/: Directory to store all of your static files, such as HTML, CSS,
The [Link] file is a configuration file that tells App Engine how to map
URLs to your static files. In the following steps, you will add handlers that will
load www/[Link] when someone visits your website, and all static files will
be stored in and called from the www directory.
1. Create a directory that has the same name as your project ID. You can find
<html>
<head>
<title>Hello, world!</title>
<linkrel="stylesheet"type="text/css"href="/css/[Link]">
19
</head>
<body>
<h1>Hello, world!</h1>
<p>
This is a simple static HTML file that will be served from Google
App
Engine.
</p>
</body>
</html>
Create an HTML file that will be served when someone navigates to the
root page of your website. Store this file in your www directory.
Optional flags:
To learn more about deploying your app from the command line, see
Deploying a Python 2 App. viewing your application
20
To launch your browser and view the app at
[Link] run the following
command:
No matter what platform you build products on, there is always some
housekeeping stuff you need to put in place before you can hit the ground
running. And deploying apps within the Google App Engine is no exception.
This will allow you to fork apps onto your local machine, make changes
(edit and develop the app), and deploy your app back to the cloud.
After downloading the SDK, launch the App Engine launcher, go to Edit
-> Preferences and make sure you set the path for where you installed Python
in step 1 above.
Set the Python path in Google App Engine launcher That’s all you need.
Your local machine should now be ready to build webapps.
This is often the most confusing part of the entire setup. Things you should
know when you sign-up:
21
2. The trial includes $300 of credit that can be used during the one year
trial period.
3. You will need to add a credit card to sign-up (for verification purposes).
4. You will not be charged during the sign-up process.
5. You will not be charged during the trial period as long as you do not cross
the credit limit offered.
The next step is to create a new Python project that you can work on.
Follow the screenshots below to create a new project.
The next step in the process is to fork the app on your local machine. This will
allow you to make changes to the app locally and deploy it whenever you wish to.
Hit the create button, and you should see your app listed on the window that
follows. You should also check that you now see some files in your local
storage (the directory you chose in the screenshot above) after this step.
22
Step 5 : Run the app locally
Before you go ahead and make some changes to the app, it is important to
check whether or not you have executed all the above steps correctly. This can be
done by simply running the app locally.
Select the app and hit the run button on the window.
Wait for a few seconds until you can hit the Browse button. Once the
Browse button becomes clickable, click it. This should take you to the browser,
and you should see the hello world text appear in your browser window.
Alternatively, you can manually go to the browser and use the port specified to
access the app. As long as you see the above screen, you are all set.
It is finally time to look at the lines of code which are running this
webapp. Open your app folder in the text editor of your choice. I recommend
Sublime text or VS Code. However, feel free to choose the one you prefer.
This file is a basic markup file that stores information (some metadata) about
the app. It is important to note the following crucial parts of the file.
1. application
This is the project ID which you should never change. This is the unique identifier
for the app
url -> script
This is the homepage for the app. In other words, this file will be rendered in
your browser when you launch the app
2. libraries This is where you can include external libraries to use within the
webapp [Link]
This is the homepage of the app (as discussed above). Note that the hello world text in
the browser window (step 5) is due to the code you see highlighted below.
23
Step 7 : Make your changes and deploy the new app
No hello world app is ever complete without the developer changing the
hello world text to something else just to make sure that everything happening
behind the scenes is working as it
should.
Go ahead and change the text in the above screenshot to something else.
Save the changes, go to the browser and refresh the page. You should see the page
with the text
“MEOW” displayed.
Finally, it is time to deploy your changes to the cloud to make them globally
accessible via a URL. Go to the App Engine launcher, select the app, and hit the
Deploy button.
Step 8 : Misc
Congratulations, you’ve finally gotten your first Python webapp deployed on the
Google App Engine. Here are some other points which you may find useful.
1. Jinja 2 is an amazing front end templating library for Python that can do
some cool stuff, such as passing objects form Python to HTML, using for
loops, if conditions, and so on directly out of the box
OUTPUT:
24
Viva Questions:
RESULT :
Thus the GAE launcher to launch the Applications is Successful.
25
Viva Questions and Answers:
26
[Link] : 5
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.
Introduction:
CloudSim
A Framework for modeling and simulation of Cloud
Computing Infrastructures and services
Originally built at the Cloud Computing Distributed Systems
(CLOUDS) Laboratory, The University of Melbourne,
Australia
It is completely written in JAVA
Main Features of CloudSiM
o Modeling and simulation
o Data centre network topologies and message-passing applications
o Dynamic insertion of simulation elements
o Stop and resume of simulation
o Policies for allocation of hosts and virtual machines
Cloudsim – Essentials
JDK 1.6 or above [Link]
Eclipse 4.2 or above [Link]
Alternatively NetBeans [Link]
Up & Running with cloudsim guide: [Link]
Cloudsim- Directory structure
o cloudsim/ -- top level CloudSim directory
o docs/ -- CloudSim API Documentation
o examples/ -- CloudSim examples
o jars/ -- CloudSim jar archives
o sources/ -- CloudSim source code
Cloudsim - Layered Architecture
CloudSim
Elements/Components Procedure to import Eclipse, Cloudsim
in your system
Step 1: Link to download Eclipse and download Eclipse for Windows 64bit into
your Loca machine.[Link]
ide- java-
eclipse-
developers
29
Step 2: Download cloudsim-3.0.3 from git hub repository in your local
machine.[Link]
Step 5: First of all, navigate to the folder where you have unzipped the eclipse folder and
open [Link]
Step 6: Now within Eclipse window navigate the menu: File -> New -> Project, to open the new
project wizard
30
Step 7: A ‗New Project‗ wizard should open. There are a number of options displayed and
you have to find & select the ‗Java Project‗ option, once done click ‘Next‗
Step 8: Now a detailed new project window will open, here you will provide the project name
and the path of CloudSim project source code, which will be done as follows:
Project Name: CloudSim.
Step 9: Unselect the ‘Use default location’ option and then click on ‘Browse’ to open the
path where you have unzipped the Cloudsim project and finally click Next to set project
settings.
Step 10: Make sure you navigate the path till you can see the bin, docs, examplesetc folder in the
navigation plane.
31
Step 11: Once done finally, click ‗Next„ to go to the next step i.e. setting up of project settings
Step 12: Now open ‘Libraries’ tab and if you do not find [Link] (here ‘x’
means the minor version release of the library which could be 2 or greater) in the list then simply
click on ‗Add External Jar’ ([Link] will be included in the project from this
step)
Step 13: Once you have clicked on ‗Add External JAR’s‗ Open the path where you have
unzipped the commons-math binaries and select ‗[Link]„ and click on
open.
Step 14: Ensure external jar that you opened in the previous step is displayed in the list and then
click on ‗Finish„ (your system may take 2-3 minutes to configure the project)
32
Step 15: Once the project is configured you can open the ‗Project Explorer‗and start exploring
the Cloudsim project. Also for the first time eclipse automatically start building the workspace
for newly configured Cloudsim project, which may take some time depending on the
configuration of the computer system.
Following is the final screen which you will see after Cloudsim is configured.
Step 16: Now just to check you within the ‗Project Explorer‗, you should navigate to the
‗examples‗ folder, then expand the package ‗[Link]‗ and double
click to open the ‗[Link]‗
33
Step 17: Now navigate to the Eclipse menu ‗Run ->Run‗ or directly use a keyboard shortcut
‘Ctrl + F11’ to execute the ‗[Link]‗.
Step 18: if is successfully executed it should be displaying the following type to output in
the console window of the Eclipse IDE.
34
Viva Questions:
RESULT:
Thus the cloudsim is simulated using Eclipse Environment successfully.
35
Viva Questions and Answers:
36
Find a procedureto transferthe files from one virtualmachineto
anothervirtualmachine.
Date:
AIM:
Source Code:
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
public class
FTPClient
{
public static void main(String args[])throws IOException
{
try
{
int number;
Socket s=new Socket("[Link]",10087); Scanner sc=new Scanner([Link]);
[Link]("Enter the file name:");
String fn=[Link]();
[Link](fn); DataInputStreamdis=new
DataInputStream([Link]());
37
int i=0;{
while((i=[Link]())!=-1)
[Link]((char)i);}
[Link]();
}
catch(Exc
eption e){
[Link]("Port not available "+e);
}
}
}
[Link]
import [Link].*;
import [Link].*;
import [Link].*;
public class
FTPServer
{
DataOutputStream dos=new
DataOutputStream([Link]()); FileInputStream
fis = new
FileInputStream("[Link]");
FileOutputStream fos = new
FileOutputStream(input);
while((num=[Link]())!= -1)
{
if(num%2==0)
38
{ [Link](num);
}
} [Link](input);
[Link]("File is sent to client"); [Link](); [Link](); } catch(Exception e)
{
[Link]("Port not available"+e);
}
}
}
[Link]
12
3
4
56
78
9
Viva Questions:
1. What is CloudSim?
2. Why is CloudSim used instead of real cloud?
3. What is a scheduling algorithm?
4. Name any one scheduling policy in CloudSim.
5. What is the role of a datacenter in CloudSim?
RESULT:
Thus the program to the File transfer operation using virtual machine was successfully
executed and verified.
39
Viva Questions and Answers:
40
[Link] :7
Install Hadoop Single Node Cluster and Run Simple Applications
DATE : Like Word Count
AIM :
To Install Hadoop single node cluster and run simple applications like wordcount.
PROCEDURE:
41
Program: [Link] import
[Link]; import
[Link];
import [Link]; import
[Link];
[Link]; import
[Link];
import [Link]; import
[Link]; import
[Link];
import [Link];
import [Link];
public class WordCount {
public static class TokenizerMapper extends Mapper { private final
static IntWritable one = new IntWritable(1); private Text word = new
Text();
public void map(Object key, Text value, Context context ) throws IOException,
InterruptedException {
StringTokenizer itr = new StringTokenizer([Link]()); while
([Link]()) {
[Link]([Link]());
[Link](word, one); } }
}
public static class IntSumReducer extends Reducer { private
IntWritable result = new IntWritable();
public void reduce(Text key, Iterable values, Context context ) throws IOException,
InterruptedException {
int sum = 0;
for (IntWritable val : values) { sum +=
[Link]();
}
42
[Link](sum); [Link](key,
result); }
}
Assuming both jar and java files in same directory run the following command to compile
root@a4cseh160:/#javac -classpath [Link] [Link]
44
Viva Questions:
1. What is Hadoop?
2. What is HDFS?
3. What is MapReduce?
4. What is a single-node Hadoop cluster?
5. What does the WordCount program do?
RESULT :
Thus the implemented Map Reduce example such as Word Count program on an file
which will count the number of times a word repeats in the given file.
45
Viva Questions and Answers:
46
[Link]
Creating and Executing your first container using Docker
Date:
AIM:
To Creating and Executing your First container using Docker
PROCEDURE:
1. Docker is fast. Unlike a virtual machine, your application can start in a
few seconds and stop just as quickly.
2. Docker is multi-platform. You can launch your container on any system.
3. Containers can be built and destroyed faster than a virtual machine.
4. No more difficulties setting up your working environment. Once your Docker
is configured, you will never have to reinstall your dependencies manually again. If
you change computers or if an employee joins your company, you only have to give
them your configuration.
5. You keep your work-space clean, as each of your environments will be isolated
and you can delete them at any time without impacting the rest.
6. It will be easier to deploy your project on your server in order to put it
online. Now let’s create your first application
➢ Now that you know what Docker is, it’s time to create your first application!
➢ The purpose of this short tutorial is to create a Python program that displays
a sentence. This program will have to be launched through a Dockerfile.
➢ You will see, it’s not very complicated once you understand the process.
Note: You will not need to install Python on your computer. It will be up to the
Docker environment to contain Python in order to execute your code. 1. Install Docker
on your machine For Ubuntu:
First, update your packages:
$ sudo apt update
Next, install docker with apt-get:
$ sudo apt install [Link]
Finally, verify that Docker is installed correctly:
$ sudo docker run hello-world
• For MacOSX: you can follow this link.
• For Windows: you can follow this link
change computers or if an employee joins your company, you only have to give them your
configuration.
7. You keep your work-space clean, as each of your environments will be isolated
and you can delete them at any time without impacting the rest.
8. It will be easier to deploy your project on your server in order to put it
online. Now let’s create your first application
➢ Now that you know what Docker is, it’s time to create your first application!
➢ The purpose of this short tutorial is to create a Python program that displays
a sentence. This program will have to be launched through a Dockerfile.
➢ You will see, it’s not very complicated once you understand the process.
47
Note: You will not need to install Python on your computer. It will be up to the Docker
environment to contain Python in order to execute your code. 1. Install Docker on your
machine For Ubuntu:
First, update your packages:
$ sudo apt update
Next, install docker with apt-get:
$ sudo apt install [Link]
Finally, verify that Docker is installed correctly:
$ sudo docker run hello-world
• For MacOSX: you can follow this link.
• For Windows: you can follow this link.
1. Create your project
In order to create your first Docker application, I invite you to create a folder on your
computer. It must contain the following two files:
• A ‘[Link]’ file (python file that will contain the code to be executed).
• A ‘Dockerfile’ file (Docker file that will contain the necessary instructions
to create the environment).
Normally you should have this folder architecture: .
├── Dockerfile
└──
[Link] 0
directories, 2 files
2. Edit the Python file
You can add the following code to the ‘[Link]’ file:
#!/usr/bin/env python3 print("Docker is magic!") Nothing exceptional, but once you see “Docker is
magic!” displayed in your terminal you will know that your Docker is working.
3. Edit the Docker file Some theory: the first thing to do when you want to create your
Dockerfile is to ask yourself what you want to do. Our goal here is to launch Python
code.
➢ To do this, our Docker must contain all the dependencies necessary to launch
Python. A linux (Ubuntu) with Python installed on it should be enough.
➢ The first step to take when you create a Docker file is to access the DockerHub
website. This site contains many pre-designed images to save your time (for example: all
images for linux or code languages).
➢ In our case, we will type ‘Python’ in the search bar. The first result is the
official image created to execute Python. Perfect, we’ll use it! # A dockerfile must always
start by importing the base image.
# We use the keyword 'FROM' to do that.
# In our example, we want import the python image.
# So we write 'python' for the image name and 'latest' for the version.
FROM python:latest
# In order to launch our python code, we must import it into our
image. # We use the keyword 'COPY' to do that.
# The first parameter '[Link]' is the name of the file on the host.
# The second parameter '/' is the path where to put the file on the
image. # Here we put the file at the image root folder. COPY
[Link] /
# We need to define the command to launch when we are going to run the image.
# We use the keyword 'CMD' to do that. # The following command will execute "python
./[Link]". CMD [ "python", "./[Link]" ]
48
3. Create the Docker image
• List your images. $ docker image ls
Once your code is ready and the Dockerfile is written, all you have to do is create your image
to contain your application.
$ docker build -t python-test .
The ’-t’ option allows you to define the name of your image. In our case we have chosen ’python-
test’ but you can put what you want.
This is a very simple tutorial for getting started with Docker. I’ll try to keep this as simple as
possible. In this, we are going to build a basic Flask application and dockerize the
application. By the end of this tutorial, you’ll get familiar with Docker and a few Docker
commands.
49
Overview of Docker
Docker Image
Dockerfile
The Dockerfile contains the steps that are needed to package your application(to
create the image). These steps include configuring the Operating system, install the
required packages or software, copy the files from one place to another.
Create the Flask application
Let’s dive into code
Flask is the micro web framework for building small web
applications.
The directory structure is as follows:
flaskapp/
├─── Dockerfile
├─── [Link]
├─── [Link]
Create a directory with the name of your choice. The command for creating a directory
in Linux is,
$mkdir flaskapp
Navigate inside the directory you created. Now create a file named [Link] and copy the following
code to it.
50
from flask import Flask app = Flask( name )@[Link]('/') def
hello_world(): return 'Hello, This is my first Docker app!'if name
== " main ": [Link](debug=True, host='[Link]')
[Link]
This is a simple Hello world Flask app. If you want to learn about flask in detail, then visit
this page and explore about flask. Let’s concentrate more on Docker now. Then create the
[Link] file. Add the following line to it.
[Link]
Now we are going to create a Dockerfile that dockerizes this application.
Flask==1.1.2
Write the Docker File
The Dockerfile should not have any extension. If you haven’t downloaded the docker yet.
Get the Docker from here. Detailed installation instructions can be found here. Create a
file called Dockerfile. This must start with capital letter D.
Dockerfile
FROM alpine:3.11RUN apk add--update pythonRUN apk add--update py-pipCOPY
./[Link]
/app/[Link] . /appWORKDIR /appRUN pip insta-
[Link] 5000CMD python [Link]
Let’s look at the instructions line by line to have a better understanding This is our base
image. There are a lot of images available in the Dockerhub. We choose alpine since it’s one
of a lightweight image. The FROM allows us to initialize the build over the base image. The
number after the colon is the version number. A valid Dockerfile always starts with FROM
keyword.
RUN apk --update add
python RUN apk add --
update py-pip
These two lines are used to install the python and the pip package respectively. The RUN
instruction will execute a new layer on top of the current image. This instruction is used to
install packages and creating new directories.
COPY ./[Link] /app/[Link] . /app
The COPY instruction is used to copy the files from source(.) to the destination(/app). The
‘.’ represents the current directory. This basically copies the flask app into the
image. WORKDIR /app
The WORKDIR sets the working
directory RUN pip install-r
[Link]
This reads the [Link] file and installs the specified packages one by one on the host
EXPOSE 5000
The EXPOSE exposes a port that is used by Flask. When you run the image you’ll get a
container that container will run on this port
CMD python [Link]
CMD is the command that is executed when you start a container. Here, you are using the
51
command to run your Python application. There can be only one CMD per Dockerfile. If
52
you specify more than one, then the last CMD will take effect. When you start a container
this command is executed. There should be only one CMD instruction in the Dockerfile. If
there is more than one, it’ll execute the last instruction.
Build the docker image
Enough of information. Let’s run the application
To build the Docker image, execute this command in the terminal in the directory we created.
$docker build -t flask-app .
The -t is used to name your image flask-app. The . , in the end, represents the current
directory. When you execute this for the first time, it’ll have to download all of the layers
that make up to build the image. After that, it’ll use the cache. If you’re not an administrator,
try to run the command with the sudo.
To run the application, execute this command $docker run -p 5000:5000 flask-app
The -p is used to map the port running inside the container to your host. Here we’re mapping
the port 5000. The value before the colon represents the port running on your host and the
value after colon represents the port running inside the container.
Now, navigate to [Link] in your browser, you’ll see the “Hello, This is my first
Docker app!” in the window.
Container
53
To know the container id enter the following command in your terminal $docker ps This lists
all the running containers in the Docker engine. This has information about containers like
its ID, created time, status and on which port it’s running. $docker ps-a This will list the
containers that have been stopped as well. $docker stop [container name] This will stop all
the running containers.
Viva Questions:
1. What is Docker?
2. What is a container?
3. Difference between container and virtual machine?
4. What is a Docker image?
5. What command is used to run a container?
RESULT:
Thus the program Creating and Executing First container using Docker is run successfully.
54
[Link]: 9 Run a container from Docker Hub
Date:
AIM:
To run a container from docker hub
PROCEDURE:
Step 1: Get the sample application. If you have git, you can clone the repository for the
sample application. ...
Step 2: Explore the Dockerfile.
... Step 3: Build your first image.
... Step 4: Run your container. ...
Step 5: Verify that your container is running.
Step 1: Sign up for a Docker account
A Docker ID grants you access to Docker Hub repositories and allows you to explore images that are
available from the community and verified publishers. You’ll also need a Docker ID to share images on
DockerHub.
To create a repository:
You need to download Docker Desktop to build, push, and pull container images.
26. [Link]
Step 5: Build and push a container image to Docker Hub from your computer
1. syntax=docker/dockerfile:1
2. FROM busybox.
3. CMD echo "Hello world! This is my first Docker image."
4. Run dockerbuild-t <your_username>/my-private-repo . to build your Docker image.
5. Run dockerrun<your_username>/my-private-repoto test your Docker image locally.
6. Run dockerpush<your_username>/my-private-repoto push your Docker image toDocker Hub.
You should see output similar to :
56
Step 6: Your repository in Docker Hub should now display a new latesttag under Tags:
You’ve successfully:
Viva Questions:
RESULT:
Thus the Run a container from Docker Hub is run successfully and output is verified.
58
Viva Questions and Answers:
59
Content Beyond Syllabus
EX NO:10
Mount The One Node Hadoop Cluster Using FUSE
DATE:
AIM:
To implement the procedure to mount the one node Hadoop cluster using
FUSE.
PROCEDURE:
OUTPUT:
$ wget
[Link] repository_1.0_all.deb
$ sudo dpkg -i cdh3-repository_1.0_all.deb
$ sudo apt-get update
$ sudo apt-get install hadoop-0.20-fuse
Once fuse-dfs is installed, go ahead and mount
RESULT:
Thus the Mount The One Node Hadoop Cluster Using FUSE run successfully and
output is verified.
52