Professional Documents
Culture Documents
CERTIFICATE
2023 – 2024.
HOD FACULTYINCHARGE
AIM:
To find procedure to run the virtual machine of different configuration and check how
many virtual machines can be utilized at particular time.
PROCEDURE:
Open Oracle virtual box manager and click create new -> virtual machine.
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 OK.The virtual
Select the iso file of the virtual OS Ubuntu and click Start.
Step 4:
Type your desired C program in text editor and save it with the extension (.c).
Step 6:
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.
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:
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.
PRE LAB VIVA QUESTIONS:
1. What is meant by virtualization?
2. What does virtual machine do?
3. What is the role of VM Ware in virtual machine?
4. Is 32 bit processor supports Virtual Machine?
5. What are two components of a virtual machine?
Thus the procedure to run different virtual machines on a single system using Oracle
Virtual Box is studied and implemented successfully.
Ex.No.2 Install a C compiler in the virtual machine created Date:
using virtual box and execute Simple Programs.
AIM:
To find a procedure to use the C compiler in the virtual machine and execute asample 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 GEDIT.It can be
opened by using the search option by typing gedit in it.
The text editor will be opened now.
Step 3:
Type your desired C program in the text editor and save it as a C file using theExtension
Step 5:
RESULT:
Thus the procedure to use the C compiler in the virtual machine and execute a sample program
is implemented successfully.
Ex.No.3 Installing and Running the Google App Engine
Date: On Windows
AIM:
To Installing and Running the Google App Engine On Windows
PROCEDURE:
PROCEDURE:
Install the latest Cloud SDK version (303.0.0)
Step 1: Download the Cloud SDK installer.
(New-Object
Alternatively, open a PowerShell terminal and run the following PowerShell commands.
Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/cha
nnels/ra
pid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")
& $env:Temp\GoogleCloudSDKInstaller.exe
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.
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.
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:
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.
• 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 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.
• Login to google account and verify the account with google for the successful
authentication.
• Download webapp2 module from https://pypi.org/project/webapp2/
handlers:
-url: / script:
test.app
• Run the gcloud prompt and give Yes option to proceed further.
Install gcloud components using the command
gcloud components install cloud-datastore-emulator
PRE LAB VIVA QUESTIONS:
1. What is Google app Engine and why it is used? 2. What two
programming languages does App Engine’s tool use?
3. Do you have to use a server to upload your application?
4. What is YAML?
5. What are the main features of Google App Engine?
MARK ALLOCATION
Total 100
RESULT:
Thus the Google App Engine installed on Windows successfully and hello world app and other
simple web applications using python/java executed successfully
Google App Engine Launch the Web Applications
Ex.No : 4
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.
By downloading, you agree to be bound by the Terms that govern use of the Cloud SDK
for App Engine.
Note: Avoid using a package manager such as apt or yum to install the Cloud SDK.
Install your preferred tooling or framework, for example you can use any of the following
frameworks to develop your Python 3 app:
• Flask
• Django
• Pyramid
• Bottle web.py
• Tornado
• www/: Directory to store all of your static files, such as HTML, CSS, images, and
JavaScript.
The app.yaml 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/index.html 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 your project
ID in the Console.
2. In directory that you just created, create a file named app.yaml.
3. Edit the app.yaml file and add the following code to the file:
Creating the index.html file
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.
<html>
<head>
<title>Hello, world!</title>
<linkrel="stylesheet"type="text/css"href="/css/style.css">
</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>
Deploying your application to App Engine
When you deploy your application files, your website will be uploaded to App Engine.
To deploy your app, run the following command from within the root directory of your
application where the app.yaml file is located:
Optional flags:
• Include the --project flag to specify an alternate Cloud Console project ID to what you
initialized as the default in the gcloud tool. Example: --project [YOUR_PROJECT_ID]
• Include the -v flag to specify a version ID, otherwise one is generated for you. Example: -
v [YOUR_VERSION_ID]
To learn more about deploying your app from the command line, see Deploying a Python 2 App.
viewing your application
To launch your browser and view the app at
https://PROJECT_ID.REGION_ID.r.appspot.com, 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:
The next step is to create a new Python project that you can work on. Follow the
screenshots below to create a new project.
Hit the create button and Google should take a few minutes to set up all that is necessary for your
newly created app.
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.
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
3. libraries
This is where you can include external libraries to use within the webapp
main.py
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.
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
2. Here’s a very useful Udacity course on web development that I have personally found quite
resourceful
3. Viewing the logs while running your webapp can be handy to debug and also discover
some bugs on the fly.
OUTPUT:
PRELAB VIVA QUESTION
MARK ALLOCATION
Total 100
Result :
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 http://tinyurl.com/JNU-JAVA
• Eclipse 4.2 or above http://tinyurl.com/JNU-Eclipse
• Alternatively NetBeanshttps://netbeans.org/downloads
❖
• Up & Running with cloudsim guide: https://goo.gl/TPL7Zh Cloudsim-
Directory structure
• cloudsim/ -- top level CloudSim directory
• docs/ -- CloudSim API Documentation
• examples/ -- CloudSim examples
• jars/ -- CloudSim jar archives
• sources/ -- CloudSim source code
❖
Cloudsim - Layered Architecture
❖
Cloudsim - Component model classes o
CloudInformationService.java o Datacenter.java,Host.java,Pe.java o
Vm.java,Cloudlet.java o DatacenterBroker.java
o Storage.java,HarddriveStorage.java, SanStorage.java
❖
Cloudsim - Major blocks/Modules o org.cloudbus.cloudsim o
org.cloudbus.cloudsim.core o org.cloudbus.cloudsim.core.predicates
o org.cloudbus.cloudsim.distributions o org.cloudbus.cloudsim.lists o
org.cloudbus.cloudsim.networko
org.cloudbus.cloudsim.network.datacenter o
org.cloudbus.cloudsim.power o org.cloudbus.cloudsim.power.lists o
org.cloudbus.cloudsim.power.models o
org.cloudbus.cloudsim.provisioners
o org.cloudbus.cloudsim.util
❖
Cloudsim - key components o Datacenter o
DataCenterCharacteristics o Host o DatacenterBroker o
RamProvisioner o BwProvisioner o Storage o Vm
o VMAllocationpolicy o VmScheduler o Cloudlet o
CloudletScheduler
o CloudInformationService o CloudSim o
CloudSimTags o SimEvent o SimEntity o
CloudsimShutdown o FutureQueue o
DefferedQueue o Predicate and associative classes.
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 Local
machine
https://www.eclipse.org/downloads/packages/release/kepler/sr1/eclipse -
ide-java-developers
Windows
Step 2: Download cloudsim-3.0.3 from git hub repository in your local machine
https://github.com/Cloudslab/cloudsim/releases/tag/cloudsim-3.0.3
Cloudsi
Step 3: Download commons-maths3-3.6.1 from git hub repository in your local machine
https://commons.apache.org/proper/commons-math/download_math.cgi
Commons-
maths3-
3.6.1 -bin.zip
Step 5: First of all, navigate to the folder where you have unzipped the eclipse folder and
open Eclipse.exe
Step 6: Now within Eclipse window navigate the menu: File -> New -> Project, to open the
new project wizard
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.
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 commons-math3-3.x.jar (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’ (commons-math3-3.x.jar 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 ‗Commons-math3-3.x.jar„ 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)
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 ‗org.cloudbus.cloudsim.examples‗ and double
click to open the ‗CloudsimExample1.java‗
.
Step 17: Now navigate to the Eclipse menu ‗Run ->Run‗ or directly use a keyboard shortcut
‘Ctrl + F11’ to execute the ‗CloudsimExample1.java‗.
Step 18: If it is successfully executed it should be displaying the following type to output inthe
MARK ALLOCATION
Total 100
Result:
Thus the cloudsim is simulated using Eclipse Environment successfully.
Ex.No : 6 Find a procedure to transfer the files from one virtual machine to another
virtual machine.
Date :
Aim:
Source Code:
FTPClient.java
import java.io.*;
import java.net.*;
import java.util.*;
public class
FTPClient
{
String fn=sc.next();
dos.writeUTF(fn);
DataInputStream dis=new DataInputStream(s.getInputStream());
String input=(String)dis.readUTF();
FileInputStream fis=new FileInputStream(input);
while((i=fis.read())!=-1)
System.out.println((char)i);
}
s.close();
}
catch(Exception e){
System.out.println("Port not available "+e);
}
}
}
FTPServer.java
import java.io.*; import
java.net.*; import
java.util.*; public class
FTPServer
{
String args[]
)
throws IOException
{
Try
{
int num;
String input=(String)dis.readUTF();
while((num=fis.read())!= -1)
{
if(num%2==0)
{ fos.write(num);
}
} dos.writeUTF(input); System.out.println("File
is sent to client");
ss.close(); s.close(); } catch(Exception e)
{
System.out.println("Port not available"+e);
}
}
}
Out.txt
1
2
3
4
5
6
7
8
9
Output:
PRELAB VIVA QUESTION
1. How to transfer the files from one virtual machine to another virtual machine?
2. How to copy files from one virtual machine to another in Linux?
3. How do I transfer a virtual machine to another computer using VMware?
4. How to transfer files from host to virtual machine in VirtualBox?
5. How to copy files from local machine to VMware virtual machine?
MARK ALLOCATION
Total 100
Result:
Thus the program to the File transfer operation using virtual machine was successfully executed
and verified.
Ex.No :7 Install Hadoop single node cluster and run simple applications like Word count
Date :
Aim :
To Install Hadoop single node cluster and run simple applications like wordcount
Procedure
→ → → → →
• In Eclipse New Java Project Provide Project Name Next Select Libraries Add
→ → → →
Externals JARs Go to Hadoop hadoop-1.2.1 select all jar files again click on Add External
→ → → → →
JARs go to hadoop hadoop-1.2.1 lib select all JAR files click on Finish.
→ → →
• Right Click on Src Folder Select Class Provide a Class name: WCE Package
→
name: com.WordCount.Example Click on Finish.
Program: WordCount.java
import java.io.IOException; import java.util.StringTokenizer;
org.apache.hadoop.fs.Path;
importorg.apache.hadoop.io.IntWritable;import
org.apache.hadoop.io.Text; import
org.apache.hadoop.mapreduce.Job; import
org.apache.hadoop.mapreduce.Mapper; import
org.apache.hadoop.mapreduce.Reducer; import
org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import
org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
val.get();
result.set(sum);
context.write(key, result);
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
System.exit(job.waitForCompletion(true) ? 0 : 1);
WordCount.java
https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-core/1.2.1
Assuming both jar and java files in same directory run the following command to compile
Syntax:
Output:
Syntax:
Output:
Output:
Syntax:
Output:
Output:
18
3 Cloud
3 Lab.
2 Grid
2 and
Step 6: Check the output in the Web UI at http://localhost:50070.In the Utilities tab select browse file system
and select the correct user. The output is available inside the output folder named user
Syntax:
Output:
MARK ALLOCATION
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.
EXNO:8
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 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 docker.io
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.
• A ‘Dockerfile’ file (Docker file that will contain the necessary instructions to create the environment).
#!/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 'main.py' 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 main.py /
# 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 ./main.py".
CMD [ "python", "./main.py" ]
4. Create the Docker image
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,
Docker is a platform for developing and running applications. It automates the deployment of applications.
It’s a tool for running applications in an isolated environment. Docker makes it easy to share an
Docker Image
Image is a template for creating an environment. The Docker image contains the Operating
System, Software, and application code. These are all packaged in a single file. Images are defined
with the Dockerfile.
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.
Flask is the micro web framework for building small web applications.
Navigate inside the directory you created. Now create a file named app.py and copy the following code to it.
app.py
from flask import Flask app = Flask(__name__)@app.route('/') def
hello_world(): return 'Hello, This is my first Docker app!'if
__name__ == "__main__": app.run(debug=True, host='0.0.0.0')
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 requirements.txt file.
requirements.txt
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 ./requirements.txt
/app/requirements.txtCOPY . /appWORKDIR /appRUN pip install-rrequirements.txtEXPOSE
5000CMD python app.py
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
execute a new layer on top of the current image. This instruction is used to install packages and creating
new directories.
COPY ./requirements.txt /app/requirements.txtCOPY . /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
This reads the requirements.txt 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 app.py
CMD is the command that is executed when you start a container. Here, you are using the command to run
your Python application. There can be only one CMD per Dockerfile. If you specify more than one, then
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.
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.
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 http://localhost:5000/ in your browser, you’ll see the “Hello, This is my first Docker
app!” in the window.
Container
This lists all the running containers in the Docker engine. This has information about containers like its ID,
This will list the containers that have been stopped as well.
$docker stop [container name]
MARK ALLOCATION
Result
Thus the program Creating and Executing First container using Docker is run successfully
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.
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
Docker Hub.
create a repository:
You need to download Docker Desktop to build, push, and pull container images.
2. Sign in to Docker Desktop using the Docker ID you created in step one.
1. In your terminal, run docker pull hello-world to pull the image from Docker Hub.
You should see output similar to:
2. $ docker pull hello-world
6. Digest:
sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac6
6dc a625
8. docker.io/library/hello-world:latest
9. Run docker run hello-world to run the image locally. You should see output similar to:
10. $ docker run hello-world
13.
16. 2. The Docker daemon pulled the "hello-world" image from the
Docker Hub.
17. (amd64)
18. 3. The Docker daemon created a new container from that image
which runs the
19. executable that produces the output you are currently reading.
20. 4. The Docker daemon streamed that output to the Docker client,
which sent
22.
25.
26. Share images, automate workflows, and more with a free Docker ID:
27. https://hub.docker.com/
28. For more examples and ideas, visit:
29. https://docs.docker.com/get-started/
Step 5: Build and push a container image to Docker Hub from your computer
2. # syntax=docker/dockerfile:1
3. FROM busybox
You must be signed in to Docker Hub through Docker Desktop or the command line, and you must
also name your images correctly, as per the above steps.
8. Your repository in Docker Hub should now display a new latest tag under Tags:
You’ve successfully:
Next steps
• Docker Desktop
• Docker Extensions
• Docker Engine
• Docker Build
• Docker Compose
Docker Hub
MARK ALLOCATION